Documentation
¶
Overview ¶
Package logging provides configurable logging utilities for squad.
Index ¶
- func Debug(message string, args ...interface{})
- func DebugContext(ctx context.Context, message string, args ...interface{})
- func DetermineLogLevel(levelStr string) slog.Level
- func Error(firstArg interface{}, args ...interface{})
- func ErrorContext(ctx context.Context, firstArg interface{}, args ...interface{})
- func Info(message string, args ...interface{})
- func InfoContext(ctx context.Context, message string, args ...interface{})
- func Initialize(logLevelStr, outputFormat string, quiet, verbose bool) error
- func IsQuiet() bool
- func Output(data interface{})
- func OutputContext(ctx context.Context, data interface{})
- func SetQuiet(quiet bool)
- func SetVerbose(verbose bool)
- func Warn(message string, args ...interface{})
- func WarnContext(ctx context.Context, message string, args ...interface{})
- func WithLogger(ctx context.Context, l *CustomLogger) context.Context
- type CustomLogger
- func (l *CustomLogger) Debug(format string, args ...interface{})
- func (l *CustomLogger) Error(firstArg interface{}, args ...interface{})
- func (l *CustomLogger) Info(format string, args ...interface{})
- func (l *CustomLogger) Output(data interface{})
- func (l *CustomLogger) SetQuiet(quiet bool)
- func (l *CustomLogger) SetVerbose(verbose bool)
- func (l *CustomLogger) Warn(format string, args ...interface{})
- func (l *CustomLogger) WithPrefix(prefix string) *CustomLogger
- type LogLevel
- type OutputType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DebugContext ¶
func DetermineLogLevel ¶
DetermineLogLevel maps a string level to its slog equivalent.
func ErrorContext ¶
func InfoContext ¶
func Initialize ¶
Initialize sets up the global logger.
func IsQuiet ¶
func IsQuiet() bool
IsQuiet reports whether the global logger suppresses non-error output.
func Output ¶
func Output(data interface{})
Output writes data using the global logger's output format.
func OutputContext ¶
func SetVerbose ¶
func SetVerbose(verbose bool)
func WarnContext ¶
func WithLogger ¶
func WithLogger(ctx context.Context, l *CustomLogger) context.Context
WithLogger returns a context that carries the provided logger.
Types ¶
type CustomLogger ¶
type CustomLogger struct {
LogLevel slog.Level
OutputType OutputType
Quiet bool
ConsoleWriter io.Writer
OutputWriter io.Writer
Verbose bool
Prefix string // Optional prefix prepended to all log messages (e.g., "[bg-1] ")
}
CustomLogger wraps logging functionality with formatting options.
func FromContext ¶
func FromContext(ctx context.Context) *CustomLogger
FromContext returns the logger stored in ctx or the global logger.
func NewCustomLogger ¶
func NewCustomLogger(level slog.Level) *CustomLogger
NewCustomLogger creates a logger with the provided minimum slog level.
func (*CustomLogger) Debug ¶
func (l *CustomLogger) Debug(format string, args ...interface{})
func (*CustomLogger) Error ¶
func (l *CustomLogger) Error(firstArg interface{}, args ...interface{})
func (*CustomLogger) Info ¶
func (l *CustomLogger) Info(format string, args ...interface{})
func (*CustomLogger) Output ¶
func (l *CustomLogger) Output(data interface{})
Output writes data using the logger's configured output format.
func (*CustomLogger) SetQuiet ¶
func (l *CustomLogger) SetQuiet(quiet bool)
func (*CustomLogger) SetVerbose ¶
func (l *CustomLogger) SetVerbose(verbose bool)
func (*CustomLogger) Warn ¶
func (l *CustomLogger) Warn(format string, args ...interface{})
func (*CustomLogger) WithPrefix ¶
func (l *CustomLogger) WithPrefix(prefix string) *CustomLogger
WithPrefix returns a shallow copy of the logger with the given prefix. The prefix is prepended to every log line, making it easy to distinguish output from different child agents or background tasks.
type OutputType ¶
type OutputType int
OutputType defines the available logger output formats.
const ( // PlainOutput emits uncolored text output. PlainOutput OutputType = iota // ColorOutput emits ANSI-colored text output. ColorOutput // JSONOutput emits structured JSON output. JSONOutput )