logging

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package logging provides an injectable logging contract and a standard-library implementation. Applications select implementations through their DI bindings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger interface {
	Debug(context.Context, string, ...any)
	Info(context.Context, string, ...any)
	Warn(context.Context, string, ...any)
	Error(context.Context, string, ...any)
	With(...any) Logger
}

Logger writes structured events. Fields are alternating string keys and values, or slog.Attr values when using SlogLogger. Implementations must be safe for concurrent use. With returns a logger with additional fields without changing the receiver. Logging does not exit the process or panic.

type Options

type Options struct {
	Output io.Writer
	Level  slog.Level
	JSON   bool
}

Options configures the default implementation. The zero value writes text events at info level or above to stderr. Output must support concurrent use when shared by independently constructed loggers.

type SlogLogger

type SlogLogger struct {
	// contains filtered or unexported fields
}

func New

func New(options Options) *SlogLogger

New creates an independent logger; it never modifies slog's global default.

func NewDefault

func NewDefault() *SlogLogger

NewDefault is the framework's fallback provider. Each DI initialization owns its own instance; this is not a global logger.

func (*SlogLogger) Debug

func (l *SlogLogger) Debug(ctx context.Context, message string, fields ...any)

func (*SlogLogger) Error

func (l *SlogLogger) Error(ctx context.Context, message string, fields ...any)

func (*SlogLogger) Info

func (l *SlogLogger) Info(ctx context.Context, message string, fields ...any)

func (*SlogLogger) Warn

func (l *SlogLogger) Warn(ctx context.Context, message string, fields ...any)

func (*SlogLogger) With

func (l *SlogLogger) With(fields ...any) Logger

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL