Documentation
¶
Index ¶
- Constants
- func SeverityToLevel(s string) (slog.Level, error)
- type Logger
- type SplitHandler
- type StdLogger
- func (sl *StdLogger) DebugContext(ctx context.Context, msg string, keysAndValues ...any)
- func (sl *StdLogger) ErrorContext(ctx context.Context, msg string, keysAndValues ...any)
- func (sl *StdLogger) InfoContext(ctx context.Context, msg string, keysAndValues ...any)
- func (sl *StdLogger) SlogLogger() *slog.Logger
- func (sl *StdLogger) WarnContext(ctx context.Context, msg string, keysAndValues ...any)
- type StructuredLogger
- func (sl *StructuredLogger) DebugContext(ctx context.Context, msg string, keysAndValues ...any)
- func (sl *StructuredLogger) ErrorContext(ctx context.Context, msg string, keysAndValues ...any)
- func (sl *StructuredLogger) InfoContext(ctx context.Context, msg string, keysAndValues ...any)
- func (sl *StructuredLogger) SlogLogger() *slog.Logger
- func (sl *StructuredLogger) WarnContext(ctx context.Context, msg string, keysAndValues ...any)
- type ValueTextHandler
Constants ¶
const ( Debug = "DEBUG" Info = "INFO" Warn = "WARN" Error = "ERROR" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Logger ¶
type Logger interface {
// DebugContext is for reporting additional information about internal operations.
DebugContext(ctx context.Context, format string, args ...any)
// InfoContext is for reporting informational messages.
InfoContext(ctx context.Context, format string, args ...any)
// WarnContext is for reporting warning messages.
WarnContext(ctx context.Context, format string, args ...any)
// ErrorContext is for reporting errors.
ErrorContext(ctx context.Context, format string, args ...any)
// Single standard slog.Logger that routes records to the outLogger or
// errLogger based on log levels
SlogLogger() *slog.Logger
}
Logger is the interface used throughout the project for logging.
func NewStdLogger ¶
NewStdLogger create a Logger that uses out and err for informational and error messages.
type StdLogger ¶
type StdLogger struct {
// contains filtered or unexported fields
}
StdLogger is the standard logger
func (*StdLogger) DebugContext ¶
DebugContext logs debug messages
func (*StdLogger) ErrorContext ¶
ErrorContext logs error messages
func (*StdLogger) InfoContext ¶
InfoContext logs debug messages
func (*StdLogger) SlogLogger ¶
SlogLogger returns a single standard *slog.Logger that routes records to the outLogger or errLogger based on the log level.
type StructuredLogger ¶
type StructuredLogger struct {
// contains filtered or unexported fields
}
func (*StructuredLogger) DebugContext ¶
func (sl *StructuredLogger) DebugContext(ctx context.Context, msg string, keysAndValues ...any)
DebugContext logs debug messages
func (*StructuredLogger) ErrorContext ¶
func (sl *StructuredLogger) ErrorContext(ctx context.Context, msg string, keysAndValues ...any)
ErrorContext logs error messages
func (*StructuredLogger) InfoContext ¶
func (sl *StructuredLogger) InfoContext(ctx context.Context, msg string, keysAndValues ...any)
InfoContext logs info messages
func (*StructuredLogger) SlogLogger ¶
func (sl *StructuredLogger) SlogLogger() *slog.Logger
SlogLogger returns a single standard *slog.Logger that routes records to the outLogger or errLogger based on the log level.
func (*StructuredLogger) WarnContext ¶
func (sl *StructuredLogger) WarnContext(ctx context.Context, msg string, keysAndValues ...any)
WarnContext logs warning messages
type ValueTextHandler ¶
type ValueTextHandler struct {
// contains filtered or unexported fields
}
ValueTextHandler is a [Handler] that writes Records to an io.Writer with values separated by spaces.
func NewValueTextHandler ¶
func NewValueTextHandler(out io.Writer, opts *slog.HandlerOptions) *ValueTextHandler
NewValueTextHandler creates a ValueTextHandler that writes to out, using the given options.
func (*ValueTextHandler) Handle ¶
Handle formats its argument [Record] as a single line of space-separated values. Example output format: 2024-11-12T15:08:11.451377-08:00 INFO "Initialized 0 sources.\n"