Documentation
¶
Overview ¶
Package log provides colored logging functions with timestamps, log levels, and structured logging support.
Index ¶
- func Debug(message string)
- func Debugf(format string, args ...interface{})
- func DisableColors()
- func EnableCallerInfo()
- func Error(message string)
- func Errorf(format string, args ...interface{})
- func Info(message string)
- func Infof(format string, args ...interface{})
- func SetConfig(config LoggerConfig)
- func SetMinLevel(level LogLevel)
- func SetOutput(writer io.Writer)
- func Success(message string)
- func Successf(format string, args ...interface{})
- func Warning(message string)
- func Warningf(format string, args ...interface{})
- type FieldLogger
- type LogLevel
- type LoggerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debug ¶ added in v1.3.7
func Debug(message string)
Debug logs a debug message with a cyan [DEBUG] prefix and timestamp. Debug messages are only shown when log level is set to LevelDebug. Now includes internal context support infrastructure.
func Debugf ¶ added in v1.3.7
func Debugf(format string, args ...interface{})
Debugf logs a formatted debug message.
func EnableCallerInfo ¶ added in v1.3.7
func EnableCallerInfo()
EnableCallerInfo enables including caller information in logs.
func Error ¶
func Error(message string)
Error logs an error message with a red [ERROR] prefix and timestamp. Now includes internal context support infrastructure.
func Errorf ¶ added in v1.3.7
func Errorf(format string, args ...interface{})
Errorf logs a formatted error message.
func Info ¶
func Info(message string)
Info logs an informational message with a blue [INFO] prefix and timestamp. Now includes internal context support infrastructure.
func Infof ¶ added in v1.3.7
func Infof(format string, args ...interface{})
Infof logs a formatted informational message.
func SetConfig ¶ added in v1.3.7
func SetConfig(config LoggerConfig)
SetConfig updates the global logger configuration.
func SetMinLevel ¶ added in v1.3.7
func SetMinLevel(level LogLevel)
SetMinLevel sets the minimum log level for output.
func Success ¶
func Success(message string)
Success logs a success message with a green [SUCCESS] prefix and timestamp. Now includes internal context support infrastructure.
func Successf ¶ added in v1.3.7
func Successf(format string, args ...interface{})
Successf logs a formatted success message.
Types ¶
type FieldLogger ¶ added in v1.3.7
type FieldLogger struct {
// contains filtered or unexported fields
}
FieldLogger provides structured logging with additional fields.
func WithFields ¶ added in v1.3.7
func WithFields(fields map[string]interface{}) *FieldLogger
WithFields creates a structured log entry with additional fields. This provides a foundation for structured logging while maintaining simplicity.
func (*FieldLogger) Debug ¶ added in v1.3.7
func (f *FieldLogger) Debug(message string)
Debug logs a debug message with structured fields.
func (*FieldLogger) Error ¶ added in v1.3.7
func (f *FieldLogger) Error(message string)
Error logs an error message with structured fields.
func (*FieldLogger) Info ¶ added in v1.3.7
func (f *FieldLogger) Info(message string)
Info logs an info message with structured fields.
func (*FieldLogger) Success ¶ added in v1.3.7
func (f *FieldLogger) Success(message string)
Success logs a success message with structured fields.
func (*FieldLogger) Warning ¶ added in v1.3.7
func (f *FieldLogger) Warning(message string)
Warning logs a warning message with structured fields.
type LogLevel ¶ added in v1.3.7
type LogLevel int
LogLevel represents the severity level of log messages.
const ( LevelDebug LogLevel = iota // LevelDebug represents debug-level messages LevelInfo // LevelInfo represents informational messages LevelSuccess // LevelSuccess represents success messages LevelWarning // LevelWarning represents warning messages LevelError // LevelError represents error messages )
type LoggerConfig ¶ added in v1.3.7
type LoggerConfig struct {
MinLevel LogLevel // MinLevel specifies the minimum log level to output
EnableColors bool // EnableColors specifies whether to use colored output
Output io.Writer // Output specifies the output writer for logs
EnableCaller bool // EnableCaller specifies whether to include caller information
TimeFormat string // TimeFormat specifies the timestamp format
}
LoggerConfig holds configuration for the logger.