Documentation
¶
Overview ¶
Package logging provides structured logging with multiple output formats and levels.
Index ¶
- func Debug(msg string, args ...any)
- func DebugIf(msg string, args ...any)
- func DebugJSON(msg string, jsonKey string, data interface{}, extraArgs ...any)
- func DebugWith(msg string, args ...any)
- func Error(msg string, args ...any)
- func ErrorWith(msg string, args ...any)
- func ErrorWithErr(msg string, err error, args ...any)
- func Info(msg string, args ...any)
- func InfoWith(msg string, args ...any)
- func IsDebugEnabled() bool
- func SetGlobalLogger(logger *Logger)
- func Warn(msg string, args ...any)
- func WarnWith(msg string, args ...any)
- func WithConversationID(ctx context.Context, id string) context.Context
- func WithRequestID(ctx context.Context, id string) context.Context
- type Config
- type Format
- type Level
- type Logger
- func (l *Logger) Close() error
- func (l *Logger) Debug(msg string, args ...any)
- func (l *Logger) DebugWith(msg string, args ...any)
- func (l *Logger) DebugWithContext(ctx context.Context, msg string, args ...any)
- func (l *Logger) Error(msg string, args ...any)
- func (l *Logger) ErrorWith(msg string, args ...any)
- func (l *Logger) ErrorWithContext(ctx context.Context, msg string, args ...any)
- func (l *Logger) ErrorWithErr(msg string, err error, args ...any)
- func (l *Logger) Info(msg string, args ...any)
- func (l *Logger) InfoWith(msg string, args ...any)
- func (l *Logger) InfoWithContext(ctx context.Context, msg string, args ...any)
- func (l *Logger) Warn(msg string, args ...any)
- func (l *Logger) WarnWith(msg string, args ...any)
- func (l *Logger) WarnWithContext(ctx context.Context, msg string, args ...any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DebugIf ¶ added in v1.6.0
DebugIf logs a debug message only if debug mode is enabled. This is more efficient than checking os.Getenv on every call.
func DebugJSON ¶ added in v1.6.0
DebugJSON logs a debug message with JSON-marshaled data. If JSON marshaling fails, logs the error and falls back to fmt.Sprintf.
func ErrorWithErr ¶
ErrorWithErr logs an error with an error object using the global logger
func IsDebugEnabled ¶ added in v1.6.0
func IsDebugEnabled() bool
IsDebugEnabled returns true if HEX_DEBUG environment variable is set. Result is cached after first check for performance.
func SetGlobalLogger ¶
func SetGlobalLogger(logger *Logger)
SetGlobalLogger sets the global logger instance
func WithConversationID ¶
WithConversationID adds a conversation ID to the context
Types ¶
type Level ¶
type Level int
Level represents log severity levels
func LevelFromString ¶
LevelFromString converts a string to a log level
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger wraps slog.Logger with additional functionality
func NewLoggerWithFile ¶
NewLoggerWithFile creates a logger that writes to a file and optionally to writer
func (*Logger) DebugWithContext ¶
DebugWithContext logs a debug message with context metadata
func (*Logger) ErrorWithContext ¶
ErrorWithContext logs an error message with context metadata
func (*Logger) ErrorWithErr ¶
ErrorWithErr logs an error message with an error object
func (*Logger) InfoWithContext ¶
InfoWithContext logs an info message with context metadata