logger

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

Functions

func Close added in v0.0.9

func Close() error

Close syncs and closes the logger

func Debug

func Debug(msg string, fields ...zap.Field)

func Error

func Error(msg string, fields ...zap.Field)

func Fatal added in v0.0.9

func Fatal(msg string, fields ...zap.Field)

Fatal logs a fatal message and exits

func GetLogger

func GetLogger() *zap.Logger

func Info

func Info(msg string, fields ...zap.Field)

func InitLogger

func InitLogger()

func InitLoggerWithConfig added in v0.0.9

func InitLoggerWithConfig(cfg *LogConfig)

InitLoggerWithConfig initializes the logger with custom configuration

func NewRequestLogger added in v0.0.9

func NewRequestLogger(requestID, userID, method, path, clientIP string) *zap.Logger

NewRequestLogger creates a logger for a specific request

func SetOutput added in v0.0.9

func SetOutput(w io.Writer)

SetOutput sets a custom writer for the logger (useful for testing)

func Sync added in v0.0.9

func Sync() error

Sync flushes any buffered log entries

func Warn

func Warn(msg string, fields ...zap.Field)

func WithContext added in v0.0.9

func WithContext(fields ...zap.Field) *zap.Logger

WithContext returns a logger with additional context fields

func WithRequestID added in v0.0.9

func WithRequestID(requestID string) *zap.Logger

WithRequestID returns a logger with request ID field

func WithUserID added in v0.0.9

func WithUserID(userID string) *zap.Logger

WithUserID returns a logger with user ID field

Types

type LogConfig added in v0.0.9

type LogConfig struct {
	// Directory for log files
	LogDir string
	// Filename for the log file
	Filename string
	// MaxSize is the maximum size in megabytes before rotation
	MaxSize int
	// MaxBackups is the maximum number of old log files to retain
	MaxBackups int
	// MaxAge is the maximum number of days to retain old log files
	MaxAge int
	// Compress determines if rotated files should be compressed
	Compress bool
	// Level is the minimum log level
	Level zapcore.Level
	// EnableConsole enables console output
	EnableConsole bool
	// ConsoleLevel is the minimum level for console output
	ConsoleLevel zapcore.Level
}

LogConfig holds logging configuration

func DefaultLogConfig added in v0.0.9

func DefaultLogConfig() *LogConfig

DefaultLogConfig returns sensible defaults for logging

Jump to

Keyboard shortcuts

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