Documentation
¶
Overview ¶
*
- @License Apache License 2.0
- @Copyright (c) 2026 OTMC Softwares. OTMC Golang Logger.
- @Contributors Nguyen Van Trung, Nguyen Thi Hoai, OTMC Contributors.
*
*
- @License Apache License 2.0
- @Copyright (c) 2026 OTMC Softwares. OTMC Golang Logger.
- @Contributors Nguyen Van Trung, Nguyen Thi Hoai, OTMC Contributors.
*
*
- @License Apache License 2.0
- @Copyright (c) 2026 OTMC Softwares. OTMC Golang Logger.
- @Contributors Nguyen Van Trung, Nguyen Thi Hoai, OTMC Contributors.
*
*
- @License Apache License 2.0
- @Copyright (c) 2026 OTMC Softwares. OTMC Golang Logger.
- @Contributors Nguyen Van Trung, Nguyen Thi Hoai, OTMC Contributors.
*
*
- @License Apache License 2.0
- @Copyright (c) 2026 OTMC Softwares. OTMC Golang Logger.
- @Contributors Nguyen Van Trung, Nguyen Thi Hoai, OTMC Contributors.
*
*
- @License Apache License 2.0
- @Copyright (c) 2026 OTMC Softwares. OTMC Golang Logger.
- @Contributors Nguyen Van Trung, Nguyen Thi Hoai, OTMC Contributors.
*
*
- @License Apache License 2.0
- @Copyright (c) 2026 OTMC Softwares. OTMC Golang Logger.
- @Contributors Nguyen Van Trung, Nguyen Thi Hoai, OTMC Contributors.
*
*
- @License Apache License 2.0
- @Copyright (c) 2026 OTMC Softwares. OTMC Golang Logger.
- @Contributors Nguyen Van Trung, Nguyen Thi Hoai, OTMC Contributors.
*
*
- @License Apache License 2.0
- @Copyright (c) 2026 OTMC Softwares. OTMC Golang Logger.
- @Contributors Nguyen Van Trung, Nguyen Thi Hoai, OTMC Contributors.
*
Index ¶
- Constants
- func Crit(format string, args ...any)
- func Debug(format string, args ...any)
- func Error(format string, args ...any)
- func Info(format string, args ...any)
- func Init(config Config)
- func SetLevel(level Level)
- func Sync() error
- func Trace(format string, args ...any)
- func Warn(format string, args ...any)
- type Config
- type Field
- type Formatter
- type Hook
- type Level
- type Logger
- type Option
- func WithCaller(enabled bool) Option
- func WithCompress(enabled bool) Option
- func WithConsole(enabled bool) Option
- func WithFile(filename string) Option
- func WithJSON(enabled bool) Option
- func WithLevel(level Level) Option
- func WithMaxAge(maxAge int) Option
- func WithMaxBackups(maxBackups int) Option
- func WithMaxSize(maxSize int) Option
- func WithStacktrace(enabled bool) Option
Constants ¶
const ( TraceLevel = internal.TraceLevel DebugLevel = internal.DebugLevel InfoLevel = internal.InfoLevel WarnLevel = internal.WarnLevel ErrorLevel = internal.ErrorLevel CritLevel = internal.CritLevel )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Level is the minimum log level to output
Level Level
// Console enables console output
Console bool
// File enables file output
File bool
// Filename is the path to the log file
Filename string
// JSON enables JSON formatting
JSON bool
// Caller enables caller information (function, file, line)
Caller bool
// Stacktrace enables stacktrace for errors
Stacktrace bool
// MaxSize is the maximum size in megabytes of a log file before it gets rotated
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 the rotated log files should be compressed using gzip
Compress bool
}
Config represents the logger configuration
type Level ¶
Level is the log level type
func ParseLevel ¶
ParseLevel parses a string level and returns the Level constant
type Logger ¶
type Logger interface {
Trace(format string, args ...any)
Debug(format string, args ...any)
Info(format string, args ...any)
Warn(format string, args ...any)
Error(format string, args ...any)
Crit(format string, args ...any)
Sync() error
}
Logger is the public logging interface
type Option ¶
type Option func(*Config)
Option is a function that configures the logger
func WithCaller ¶
WithCaller enables or disables caller information
func WithCompress ¶
WithCompress enables or disables compression of rotated log files
func WithConsole ¶
WithConsole enables or disables console output
func WithMaxAge ¶
WithMaxAge sets the maximum number of days to retain old log files
func WithMaxBackups ¶
WithMaxBackups sets the maximum number of old log files to retain
func WithMaxSize ¶
WithMaxSize sets the maximum size in megabytes before rotation
func WithStacktrace ¶
WithStacktrace enables or disables stacktrace for errors