Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Logger *slog.Logger
Logger is the global logger instance (deprecated: use GetLogger() for thread-safe access)
Functions ¶
func ParseLevel ¶
ParseLevel converts a string log level to slog.Level
func WithRequestID ¶
WithRequestID returns a logger with the request ID field added This is useful for tracing requests across log entries
Types ¶
type Config ¶
type Config struct {
// LogLevel sets the minimum log level (debug, info, warn, error)
LogLevel slog.Level
// LogFilePath is the path to the log file (empty to disable file logging)
LogFilePath string
}
Config holds logging configuration
type InitResult ¶
type InitResult struct {
// FileLoggingEnabled indicates whether file logging was successfully enabled
FileLoggingEnabled bool
// FileLoggingError contains the error if file logging failed (nil if succeeded or not attempted)
FileLoggingError error
}
InitResult contains the result of logger initialization
func InitLogger ¶
func InitLogger(cfg Config) (*InitResult, error)
InitLogger initializes the global logger with JSON structured logging It always logs to stdout and optionally logs to a file if LogFilePath is set Returns InitResult indicating whether file logging was enabled and any errors encountered
Click to show internal directories.
Click to hide internal directories.