logging

package module
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

README

logging

unified logging package

Documentation

Overview

wrappers for slog methods see: https://pkg.go.dev/log/slog#example-package-Wrapping

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Audit

func Audit(ctx context.Context, msg string, args ...any)

func Debug

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

func Error

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

func FileDriver

func FileDriver(logPath string, o ...*Options) (logger *slog.Logger, closer func(), err error)

func Info

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

func Stderr

func Stderr(o ...*Options) *slog.Logger

func Stdout

func Stdout(o ...*Options) *slog.Logger

func Trace

func Trace(ctx context.Context, msg string, args ...any)

func Warn

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

Types

type Level

type Level slog.Level
const (
	LevelError Level = Level(slog.LevelError)
	LevelWarn  Level = Level(slog.LevelWarn)
	LevelAudit Level = Level(slog.LevelInfo + 2)
	LevelInfo  Level = Level(slog.LevelInfo)
	LevelDebug Level = Level(slog.LevelDebug)
	LevelTrace Level = Level(slog.LevelDebug - 4)
)

func LevelFromString

func LevelFromString(levelString string) Level

func (Level) Level

func (level Level) Level() slog.Level

Level implements slog.Leveler.

func (Level) MarshalJSON

func (level Level) MarshalJSON() ([]byte, error)

func (Level) String

func (level Level) String() string

func (*Level) UnmarshalJSON

func (level *Level) UnmarshalJSON(data []byte) error

type Logger

type Logger interface {
	Error(ctx context.Context, msg string, args ...any)
	Warn(ctx context.Context, msg string, args ...any)
	Audit(ctx context.Context, msg string, args ...any)
	Info(ctx context.Context, msg string, args ...any)
	Debug(ctx context.Context, msg string, args ...any)
	Trace(ctx context.Context, msg string, args ...any)
}

type Options

type Options struct {
	Global      bool
	Level       slog.Leveler
	ContextKeys []any
	// contains filtered or unexported fields
}

func (*Options) Audit

func (o *Options) Audit(ctx context.Context, msg string, args ...any)

func (*Options) Debug

func (o *Options) Debug(ctx context.Context, msg string, args ...any)

func (*Options) Enabled

func (o *Options) Enabled(ctx context.Context, level slog.Level) bool

func (*Options) Error

func (o *Options) Error(ctx context.Context, msg string, args ...any)

func (*Options) Handle

func (o *Options) Handle(ctx context.Context, record slog.Record) error

func (*Options) Info

func (o *Options) Info(ctx context.Context, msg string, args ...any)

func (*Options) Trace

func (o *Options) Trace(ctx context.Context, msg string, args ...any)

func (*Options) Warn

func (o *Options) Warn(ctx context.Context, msg string, args ...any)

func (*Options) WithAttrs

func (o *Options) WithAttrs(attrs []slog.Attr) slog.Handler

func (*Options) WithGroup

func (o *Options) WithGroup(name string) slog.Handler

Jump to

Keyboard shortcuts

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