Documentation
¶
Overview ¶
Package logger provides a flexible and configurable logging solution with support for different log levels, colored output, and webhook notifications.
Index ¶
- type LogLevel
- type Logger
- func (l *Logger) Log(logLevel LogLevel, format string, v ...any)
- func (l *Logger) LogDebug(format string, v ...any)
- func (l *Logger) LogError(format string, v ...any)
- func (l *Logger) LogFatal(format string, v ...any)
- func (l *Logger) LogInfo(format string, v ...any)
- func (l *Logger) LogWarn(format string, v ...any)
- type WebhookConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogLevel ¶ added in v1.0.0
type LogLevel string
LogLevel represents the severity level of a log message
type Logger ¶ added in v0.0.5
type Logger struct {
// ServiceName identifies the service generating the logs
ServiceName string
// LogContextName provides additional context for the logs
LogContextName string
// DebugEnabled controls whether debug messages are logged
DebugEnabled bool
// CaptureExceptionFunc is an optional callback for error handling
CaptureExceptionFunc func(err error)
// WebhookConfig contains settings for webhook notifications
WebhookConfig WebhookConfig
}
Logger is the main logging structure that provides methods for different log levels
func NewLogger ¶ added in v1.0.0
func NewLogger(serviceName, logContextName string, debugEnabled bool, webhookConfig WebhookConfig) *Logger
NewLogger creates a new Logger instance with the given configuration
func (*Logger) LogDebug ¶ added in v0.0.5
LogDebug sends a debug log message if debug logging is enabled
func (*Logger) LogError ¶ added in v0.0.5
LogError sends an error log message and optionally triggers webhook and exception capture
func (*Logger) LogFatal ¶ added in v0.0.5
LogFatal sends a fatal error log message, triggers webhook if configured, and exits the program
type WebhookConfig ¶ added in v0.0.5
type WebhookConfig struct {
// URL is the endpoint where log messages will be sent
URL string `json:"url"`
// SendError determines if error logs should trigger webhook notifications
SendError bool `json:"sendError"`
// SendFatal determines if fatal logs should trigger webhook notifications
SendFatal bool `json:"sendFatal"`
// SendWarn determines if warning logs should trigger webhook notifications
SendWarn bool `json:"sendWarn"`
}
WebhookConfig defines the configuration for webhook notifications