Documentation
¶
Overview ¶
Package logging provides a structured logging interface compatible with slog levels and common logging utilities for the MindTrial application.
Index ¶
Constants ¶
const ( LevelTrace = slog.Level(-8) // most verbose LevelDebug = slog.LevelDebug LevelInfo = slog.LevelInfo LevelWarn = slog.LevelWarn LevelError = slog.LevelError // least verbose )
Common logging levels for structured logging.
const UnknownLogValue = "<unknown>"
UnknownLogValue is the placeholder text used when logging nil or unknown values.
Variables ¶
This section is empty.
Functions ¶
func FormatLogInt64 ¶
FormatLogInt64 formats an int64 pointer value for logging. If the pointer is nil, it returns a placeholder value.
func FormatLogText ¶
FormatLogText formats a slice of strings for logging with tab indentation and double-newline separation. If the slice is empty, it returns a tab-indented placeholder value.
Types ¶
type Logger ¶
type Logger interface {
// Message logs a message at the specified level with optional format arguments.
Message(ctx context.Context, level slog.Level, msg string, args ...any)
// Error logs an error at the specified level with optional format arguments.
Error(ctx context.Context, level slog.Level, err error, msg string, args ...any)
// WithContext returns a new Logger that appends the specified context to the existing prefix.
// This allows for hierarchical logging where components can add their context
// without affecting the original logger instance. Each call extends the prefix chain.
WithContext(context string) Logger
}
Logger defines a generic logging interface following slog style with log levels. It provides structured logging capabilities for both regular messages and error handling.