logger

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

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

Logger is a wrapper around slog.Logger with toggle capability and caller fix.

func New

func New(opts ...Option) *Logger

New creates a new Logger instance.

func (*Logger) Debug

func (l *Logger) Debug(ctx context.Context, msg string, args ...any)

Debug logs at LevelDebug with context (auto trace_id injection).

func (*Logger) Error

func (l *Logger) Error(ctx context.Context, msg string, args ...any)

Error logs at LevelError with context (auto trace_id injection).

func (*Logger) GetSlog

func (l *Logger) GetSlog() *slog.Logger

Compatibility with bang-go/opt if needed, or just helpers

func (*Logger) Info

func (l *Logger) Info(ctx context.Context, msg string, args ...any)

Info logs at LevelInfo with context (auto trace_id injection).

func (*Logger) IsEnabled

func (l *Logger) IsEnabled() bool

IsEnabled checks if logging is enabled

func (*Logger) Toggle

func (l *Logger) Toggle(enable bool)

Toggle enables or disables log output

func (*Logger) Warn

func (l *Logger) Warn(ctx context.Context, msg string, args ...any)

Warn logs at LevelWarn with context (auto trace_id injection).

func (*Logger) With

func (l *Logger) With(args ...any) *Logger

With returns a new Logger with the given attributes.

func (*Logger) WithGroup

func (l *Logger) WithGroup(name string) *Logger

WithGroup returns a new Logger that starts a group.

type Option

type Option func(*options)

Option configures the Logger

func WithAddSource

func WithAddSource(add bool) Option

func WithFormat

func WithFormat(format string) Option

func WithLevel

func WithLevel(level string) Option

func WithOutput

func WithOutput(w io.Writer) Option

Jump to

Keyboard shortcuts

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