Documentation
¶
Index ¶
- func Debug(msg string, fields ...map[string]interface{})
- func DebugWithContext(msg string, extraFields ...map[string]interface{})
- func Debugf(format string, v ...interface{})
- func Error(msg string, fields ...map[string]interface{})
- func Errorf(format string, v ...interface{})
- func Fatal(msg string, fields ...map[string]interface{})
- func Fatalf(format string, v ...interface{})
- func Info(msg string, fields ...map[string]interface{})
- func Infof(format string, v ...interface{})
- func InitDefault()
- func InitForTesting()
- func InitFromConfig(config LoggerConfig) error
- func InitWithLevel(level LogLevel)
- func IsDebugEnabled() bool
- func IsTraceEnabled() bool
- func IsVerboseEnabled() bool
- func SetGlobalDebugMode(mode DebugMode)
- func SetGlobalDebugModeFromString(mode string)
- func SetGlobalFormat(format string)
- func SetGlobalLevel(level LogLevel)
- func Trace(msg string, fields ...map[string]interface{})
- func TraceFunction(funcName string) func()
- func TraceWithContext(msg string, extraFields ...map[string]interface{})
- func Tracef(format string, v ...interface{})
- func Verbose(msg string, fields ...map[string]interface{})
- func VerboseWithContext(msg string, extraFields ...map[string]interface{})
- func Verbosef(format string, v ...interface{})
- func Warn(msg string, fields ...map[string]interface{})
- func Warnf(format string, v ...interface{})
- type Config
- type DebugConfig
- type DebugLogger
- func (dl *DebugLogger) DebugWithContext(msg string, extraFields ...map[string]interface{})
- func (dl *DebugLogger) IsEnabled(level LogLevel) bool
- func (dl *DebugLogger) SetDebugMode(mode DebugMode)
- func (dl *DebugLogger) TraceFunction(funcName string) func()
- func (dl *DebugLogger) TraceWithContext(msg string, extraFields ...map[string]interface{})
- func (dl *DebugLogger) VerboseWithContext(msg string, extraFields ...map[string]interface{})
- type DebugMode
- type FieldLogger
- func (fl *FieldLogger) Debug(msg string)
- func (fl *FieldLogger) Debugf(format string, v ...interface{})
- func (fl *FieldLogger) Error(msg string)
- func (fl *FieldLogger) Errorf(format string, v ...interface{})
- func (fl *FieldLogger) Fatal(msg string)
- func (fl *FieldLogger) Fatalf(format string, v ...interface{})
- func (fl *FieldLogger) Info(msg string)
- func (fl *FieldLogger) Infof(format string, v ...interface{})
- func (fl *FieldLogger) Trace(msg string)
- func (fl *FieldLogger) Tracef(format string, v ...interface{})
- func (fl *FieldLogger) Verbose(msg string)
- func (fl *FieldLogger) Verbosef(format string, v ...interface{})
- func (fl *FieldLogger) Warn(msg string)
- func (fl *FieldLogger) Warnf(format string, v ...interface{})
- type LogLevel
- type Logger
- func (l *Logger) Debug(msg string, fields ...map[string]interface{})
- func (l *Logger) Debugf(format string, v ...interface{})
- func (l *Logger) Error(msg string, fields ...map[string]interface{})
- func (l *Logger) Errorf(format string, v ...interface{})
- func (l *Logger) Fatal(msg string, fields ...map[string]interface{})
- func (l *Logger) Fatalf(format string, v ...interface{})
- func (l *Logger) Info(msg string, fields ...map[string]interface{})
- func (l *Logger) Infof(format string, v ...interface{})
- func (l *Logger) SetFormat(format string)
- func (l *Logger) SetLevel(level LogLevel)
- func (l *Logger) Trace(msg string, fields ...map[string]interface{})
- func (l *Logger) Tracef(format string, v ...interface{})
- func (l *Logger) Verbose(msg string, fields ...map[string]interface{})
- func (l *Logger) Verbosef(format string, v ...interface{})
- func (l *Logger) Warn(msg string, fields ...map[string]interface{})
- func (l *Logger) Warnf(format string, v ...interface{})
- func (l *Logger) WithFields(fields map[string]interface{}) *FieldLogger
- type LoggerConfig
- type RotationConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DebugWithContext ¶
Global debug functions
func InitForTesting ¶
func InitForTesting()
InitForTesting initializes a logger suitable for testing
func InitFromConfig ¶
func InitFromConfig(config LoggerConfig) error
InitFromConfig initializes the global logger from configuration
func InitWithLevel ¶
func InitWithLevel(level LogLevel)
InitWithLevel initializes the logger with a specific log level
func IsVerboseEnabled ¶
func IsVerboseEnabled() bool
IsVerboseEnabled checks if verbose logging is enabled
func SetGlobalDebugMode ¶
func SetGlobalDebugMode(mode DebugMode)
SetGlobalDebugMode sets the debug mode for the global debug logger
func SetGlobalDebugModeFromString ¶
func SetGlobalDebugModeFromString(mode string)
SetGlobalDebugModeFromString sets the debug mode from string
func SetGlobalFormat ¶
func SetGlobalFormat(format string)
SetGlobalFormat sets the format for the global logger
func SetGlobalLevel ¶
func SetGlobalLevel(level LogLevel)
SetGlobalLevel sets the log level for the global logger
func TraceFunction ¶
func TraceFunction(funcName string) func()
func TraceWithContext ¶
func VerboseWithContext ¶
Types ¶
type Config ¶
type Config struct {
Level LogLevel
Format string // "text" or "json"
Output io.Writer
Timestamp bool
Caller bool
Prefix string
}
Config represents logger configuration
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a default logger configuration
type DebugConfig ¶
type DebugConfig struct {
Mode DebugMode
ShowCaller bool
ShowTimestamp bool
ShowGoroutine bool
ShowMemStats bool
IncludeStack bool
MaxStackDepth int
}
DebugConfig contains debug-specific configuration
func DefaultDebugConfig ¶
func DefaultDebugConfig() *DebugConfig
DefaultDebugConfig returns a default debug configuration
type DebugLogger ¶
type DebugLogger struct {
// contains filtered or unexported fields
}
DebugLogger provides enhanced debugging capabilities
func GetGlobalDebugLogger ¶
func GetGlobalDebugLogger() *DebugLogger
GetGlobalDebugLogger returns the global debug logger
func NewDebugLogger ¶
func NewDebugLogger(logger *Logger, config *DebugConfig) *DebugLogger
NewDebugLogger creates a new debug logger
func (*DebugLogger) DebugWithContext ¶
func (dl *DebugLogger) DebugWithContext(msg string, extraFields ...map[string]interface{})
DebugWithContext logs a debug message with enhanced context
func (*DebugLogger) IsEnabled ¶
func (dl *DebugLogger) IsEnabled(level LogLevel) bool
IsEnabled checks if debug logging is enabled for the given level
func (*DebugLogger) SetDebugMode ¶
func (dl *DebugLogger) SetDebugMode(mode DebugMode)
SetDebugMode sets the debug mode
func (*DebugLogger) TraceFunction ¶
func (dl *DebugLogger) TraceFunction(funcName string) func()
TraceFunction logs function entry and exit
func (*DebugLogger) TraceWithContext ¶
func (dl *DebugLogger) TraceWithContext(msg string, extraFields ...map[string]interface{})
TraceWithContext logs a trace message with enhanced context
func (*DebugLogger) VerboseWithContext ¶
func (dl *DebugLogger) VerboseWithContext(msg string, extraFields ...map[string]interface{})
VerboseWithContext logs a verbose message with enhanced context
type DebugMode ¶
type DebugMode int
DebugMode represents different debug modes
func ParseDebugMode ¶
ParseDebugMode parses a string into a DebugMode
type FieldLogger ¶
type FieldLogger struct {
// contains filtered or unexported fields
}
FieldLogger wraps Logger with predefined fields
func (*FieldLogger) Debug ¶
func (fl *FieldLogger) Debug(msg string)
Debug logs a debug message with predefined fields
func (*FieldLogger) Debugf ¶
func (fl *FieldLogger) Debugf(format string, v ...interface{})
Debugf logs a formatted debug message with predefined fields
func (*FieldLogger) Error ¶
func (fl *FieldLogger) Error(msg string)
Error logs an error message with predefined fields
func (*FieldLogger) Errorf ¶
func (fl *FieldLogger) Errorf(format string, v ...interface{})
Errorf logs a formatted error message with predefined fields
func (*FieldLogger) Fatal ¶
func (fl *FieldLogger) Fatal(msg string)
Fatal logs a fatal message with predefined fields and exits
func (*FieldLogger) Fatalf ¶
func (fl *FieldLogger) Fatalf(format string, v ...interface{})
Fatalf logs a formatted fatal message with predefined fields and exits
func (*FieldLogger) Info ¶
func (fl *FieldLogger) Info(msg string)
Info logs an info message with predefined fields
func (*FieldLogger) Infof ¶
func (fl *FieldLogger) Infof(format string, v ...interface{})
Infof logs a formatted info message with predefined fields
func (*FieldLogger) Trace ¶
func (fl *FieldLogger) Trace(msg string)
Trace logs a trace message with predefined fields
func (*FieldLogger) Tracef ¶
func (fl *FieldLogger) Tracef(format string, v ...interface{})
Tracef logs a formatted trace message with predefined fields
func (*FieldLogger) Verbose ¶
func (fl *FieldLogger) Verbose(msg string)
Verbose logs a verbose message with predefined fields
func (*FieldLogger) Verbosef ¶
func (fl *FieldLogger) Verbosef(format string, v ...interface{})
Verbosef logs a formatted verbose message with predefined fields
func (*FieldLogger) Warn ¶
func (fl *FieldLogger) Warn(msg string)
Warn logs a warning message with predefined fields
func (*FieldLogger) Warnf ¶
func (fl *FieldLogger) Warnf(format string, v ...interface{})
Warnf logs a formatted warning message with predefined fields
type LogLevel ¶
type LogLevel int
LogLevel represents the logging level
func ParseLogLevel ¶
ParseLogLevel parses a string into a LogLevel
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger provides a configurable logging interface
func GetGlobalLogger ¶
func GetGlobalLogger() *Logger
GetGlobalLogger returns the global logger instance
func NewWithConfig ¶
NewWithConfig creates a new logger instance with custom configuration
func (*Logger) WithFields ¶
func (l *Logger) WithFields(fields map[string]interface{}) *FieldLogger
WithFields creates a logger with predefined fields
type LoggerConfig ¶
type LoggerConfig struct {
Level string
Format string
Output string
Timestamp bool
Caller bool
Prefix string
Rotation RotationConfig
}
LoggerConfig represents the configuration structure for logger initialization