logger

package
v1.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FiberMiddleware

func FiberMiddleware(logger *zap.Logger) fiber.Handler

FiberMiddleware creates a Fiber middleware using the provided logger

func NewDevelopmentLogger

func NewDevelopmentLogger() (*zap.Logger, error)

NewDevelopmentLogger creates a development logger (console output, colored)

func NewLogger

func NewLogger(config *Config) (*zap.Logger, error)

NewLogger creates a new Zap logger based on configuration

func NewProductionLogger

func NewProductionLogger(filePath string, maxSizeMB, maxBackups, maxAge int) (*zap.Logger, error)

NewProductionLogger creates a production logger (JSON output, file rotation)

func SetupFiberLogger

func SetupFiberLogger(app *fiber.App, config *Config) (*zap.Logger, error)

SetupFiberLogger sets up structured logging for a Fiber app Returns the logger instance for cleanup (call logger.Sync() on shutdown)

Types

type Config

type Config struct {
	Enabled    *bool  `yaml:"enabled"`
	FilePath   string `yaml:"file_path"`   // Path to log file (empty for stdout only)
	MaxSize    int64  `yaml:"max_size"`    // Max size in bytes before rotation
	MaxBackups int    `yaml:"max_backups"` // Max number of backup files to retain
	MaxAge     int    `yaml:"max_age"`     // Max age of backup files in days
	Level      string `yaml:"level"`       // Log level: debug, info, warn, error (default: info)
}

Config holds logging configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a default logging configuration

func (*Config) IsEnabled

func (c *Config) IsEnabled() bool

IsEnabled returns true if logging is enabled

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL