Documentation
¶
Index ¶
- Constants
- Variables
- func Debug(msg string, fields ...zap.Field)
- func Error(msg string, fields ...zap.Field)
- func Errors(msg string, errs ...error)
- func Fatal(msg string, fields ...zap.Field)
- func Info(msg string, fields ...zap.Field)
- func InitLogger(logConfig *Config)
- func Panic(msg string, fields ...zap.Field)
- func PanicErrors(msg string, errs ...error)
- func PrintPanic(errs ...error)
- func Sync() error
- func Warn(msg string, fields ...zap.Field)
- type Config
Constants ¶
View Source
const ConfigKey = "web.log"
ConfigKey is the configuration key under which logger settings are stored.
Variables ¶
View Source
var TimestampFormat = "2006-01-02 15:04:05"
TimestampFormat is the time format used in log output.
Functions ¶
func InitLogger ¶
func InitLogger(logConfig *Config)
InitLogger initializes or reconfigures the global logger with the given config.
func Panic ¶ added in v0.1.1
Panic logs a panic message and then panics. Error fields are also printed via log.Printf for stack trace visibility.
func PanicErrors ¶ added in v0.1.1
PanicErrors logs a panic message with error values and prints them via log.Printf. Unlike zap.Panic, this only logs the message without actually panicking.
func PrintPanic ¶ added in v0.1.3
func PrintPanic(errs ...error)
PrintPanic prints error stack traces via log.Printf without panicking.
Types ¶
type Config ¶ added in v0.1.1
type Config struct {
Level string // Log level: debug, info, warn, error
Path string // Log file path
Write bool // Whether to enable file-based logging
MaxSize int // Max size per log file (MB), default 500
MaxBackups int // Max number of old log files retained, default 3
MaxAge int // Max days to retain old log files, default 30
Compress bool // Whether to compress old log files, default true
LocalTime bool // Whether to use local time, default false (UTC)
}
Config holds the logger configuration settings.
Click to show internal directories.
Click to hide internal directories.