Documentation
¶
Index ¶
- Variables
- func Close() error
- func Debug(msg string, fields ...zap.Field)
- func Error(msg string, fields ...zap.Field)
- func Fatal(msg string, fields ...zap.Field)
- func GetLogger() *zap.Logger
- func Info(msg string, fields ...zap.Field)
- func InitLogger()
- func InitLoggerWithConfig(cfg *LogConfig)
- func NewRequestLogger(requestID, userID, method, path, clientIP string) *zap.Logger
- func SetOutput(w io.Writer)
- func Sync() error
- func Warn(msg string, fields ...zap.Field)
- func WithContext(fields ...zap.Field) *zap.Logger
- func WithRequestID(requestID string) *zap.Logger
- func WithUserID(userID string) *zap.Logger
- type LogConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var Log *zap.Logger
Functions ¶
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
NewRequestLogger creates a logger for a specific request
func WithContext ¶ added in v0.0.9
WithContext returns a logger with additional context fields
func WithRequestID ¶ added in v0.0.9
WithRequestID returns a logger with request ID field
func WithUserID ¶ added in v0.0.9
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
Click to show internal directories.
Click to hide internal directories.