gologger

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 9 Imported by: 0

README

Go Logger

used in AZF

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Log *zap.Logger
)

Functions

func Close

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

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

func InitLoggerWithConfig(cfg *LogConfig)

func NewRequestLogger

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

NewRequestLogger creates a logger for a specific request

func SetOutput

func SetOutput(w io.Writer)

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

func Sync

func Sync() error

Sync flushes any buffered log entries

func Warn

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

func WithContext

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

WithContext returns a logger with additional context fields

func WithRequestID

func WithRequestID(requestID string) *zap.Logger

WithRequestID returns a logger with request ID field

func WithUserID

func WithUserID(userID string) *zap.Logger

WithUserID returns a logger with user ID field

Types

type LogConfig

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

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