logging

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsoleHandler

type ConsoleHandler struct {
	slog.Handler
	// contains filtered or unexported fields
}

func (*ConsoleHandler) Handle

func (h *ConsoleHandler) Handle(ctx context.Context, r slog.Record) error

type ConsoleOptions added in v0.20.0

type ConsoleOptions struct {
	Level       Level
	Theme       ansicolor.Theme
	ReplaceAttr func(groups []string, a slog.Attr) slog.Attr
	AddSource   bool
}

func ConsoleDefaultOptions added in v0.20.0

func ConsoleDefaultOptions() ConsoleOptions

type DefaultLogger

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

func Console

func Console(opts ConsoleOptions) *DefaultLogger

func Default

func Default(lvl Level) *DefaultLogger

func New

func New(w io.Writer, lvl Level) *DefaultLogger

func (*DefaultLogger) BUG

func (l *DefaultLogger) BUG(msg string, attrs ...slog.Attr)

func (*DefaultLogger) Debug

func (l *DefaultLogger) Debug(msg string, attrs ...slog.Attr)

func (*DefaultLogger) Deprecated

func (l *DefaultLogger) Deprecated(msg string, attrs ...slog.Attr)

func (*DefaultLogger) Enabled

func (l *DefaultLogger) Enabled(lvl Level) bool

func (*DefaultLogger) Error

func (l *DefaultLogger) Error(msg string, attrs ...slog.Attr)

func (*DefaultLogger) HTTP

func (l *DefaultLogger) HTTP(status int, method, path string, attrs ...slog.Attr)

func (*DefaultLogger) Handle

func (l *DefaultLogger) Handle(r slog.Record) error

func (*DefaultLogger) Info

func (l *DefaultLogger) Info(msg string, attrs ...slog.Attr)

func (*DefaultLogger) Level

func (l *DefaultLogger) Level() Level

func (*DefaultLogger) LogDepth

func (l *DefaultLogger) LogDepth(depth int, lvl Level, msg string, attrs ...slog.Attr)

LogDepth logs a message with additional context at a given depth. The depth is the number of stack frames to ascend when logging the message. It is useful only when AddSource is enabled.

func (*DefaultLogger) Logger added in v0.17.0

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

func (*DefaultLogger) NotImplemented

func (l *DefaultLogger) NotImplemented(msg string, attrs ...slog.Attr)

func (*DefaultLogger) Notice

func (l *DefaultLogger) Notice(msg string, attrs ...slog.Attr)

func (*DefaultLogger) Ok

func (l *DefaultLogger) Ok(msg string, attrs ...slog.Attr)

func (*DefaultLogger) Printf added in v0.14.0

func (l *DefaultLogger) Printf(format string, v ...any)

func (*DefaultLogger) Println

func (l *DefaultLogger) Println(msg string, attrs ...slog.Attr)

func (*DefaultLogger) SetLevel

func (l *DefaultLogger) SetLevel(lvl Level)

func (*DefaultLogger) SystemDebug

func (l *DefaultLogger) SystemDebug(msg string, attrs ...slog.Attr)

func (*DefaultLogger) Warn

func (l *DefaultLogger) Warn(msg string, attrs ...slog.Attr)

type Level

type Level int
const (
	LevelSystemDebug    Level = Level(levelSystemDebug)
	LevelDebug          Level = Level(levelDebug)
	LevelInfo           Level = Level(levelInfo)
	LevelOk             Level = Level(levelOk)
	LevelNotice         Level = Level(levelNotice)
	LevelNotImplemented Level = Level(levelNotImplemented)
	LevelWarn           Level = Level(levelWarn)
	LevelDeprecated     Level = Level(levelDeprecated)
	LevelError          Level = Level(levelError)
	LevelBUG            Level = Level(levelBUG)
	LevelAlways         Level = Level(levelAlways)
	LevelQuiet          Level = Level(levelQuiet)
)

func (Level) String

func (l Level) String() string

type Logger

type Logger interface {
	SystemDebug(msg string, attrs ...slog.Attr)
	Debug(msg string, attrs ...slog.Attr)
	Info(msg string, attrs ...slog.Attr)
	Ok(msg string, attrs ...slog.Attr)
	Notice(msg string, attrs ...slog.Attr)
	NotImplemented(msg string, attrs ...slog.Attr)
	Warn(msg string, attrs ...slog.Attr)
	Deprecated(msg string, attrs ...slog.Attr)
	Error(msg string, attrs ...slog.Attr)
	BUG(msg string, attrs ...slog.Attr)
	Println(msg string, attrs ...slog.Attr)
	Printf(format string, v ...any)
	HTTP(status int, method, path string, attrs ...slog.Attr)
	Handle(r slog.Record) error

	Enabled(lvl Level) bool
	Level() Level
	SetLevel(lvl Level)

	LogDepth(depth int, lvl Level, msg string, attrs ...slog.Attr)

	Logger() *slog.Logger
}

type QueueRecord

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

func NewQueueRecord

func NewQueueRecord(lvl Level, msg string, detph int, attrs ...slog.Attr) QueueRecord

func (QueueRecord) Record

func (qr QueueRecord) Record() slog.Record

type TestLogger

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

func NewTestLogger

func NewTestLogger(lvl Level) *TestLogger

NewTestLogger returns a new test logger that writes to a buffer with slog.JSONHandler. The buffer can be accessed via the Output method.

func (*TestLogger) BUG

func (l *TestLogger) BUG(msg string, attrs ...slog.Attr)

func (*TestLogger) Debug

func (l *TestLogger) Debug(msg string, attrs ...slog.Attr)

func (*TestLogger) Deprecated

func (l *TestLogger) Deprecated(msg string, attrs ...slog.Attr)

func (*TestLogger) Enabled

func (l *TestLogger) Enabled(lvl Level) bool

func (*TestLogger) Error

func (l *TestLogger) Error(msg string, attrs ...slog.Attr)

func (*TestLogger) HTTP

func (l *TestLogger) HTTP(status int, method, path string, attrs ...slog.Attr)

func (*TestLogger) Handle

func (l *TestLogger) Handle(r slog.Record) error

func (*TestLogger) Info

func (l *TestLogger) Info(msg string, attrs ...slog.Attr)

func (*TestLogger) Level

func (l *TestLogger) Level() Level

func (*TestLogger) LogDepth

func (l *TestLogger) LogDepth(depth int, lvl Level, msg string, attrs ...slog.Attr)

func (*TestLogger) Logger added in v0.17.0

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

func (*TestLogger) NotImplemented

func (l *TestLogger) NotImplemented(msg string, attrs ...slog.Attr)

func (*TestLogger) Notice

func (l *TestLogger) Notice(msg string, attrs ...slog.Attr)

func (*TestLogger) Ok

func (l *TestLogger) Ok(msg string, attrs ...slog.Attr)

func (*TestLogger) Output

func (tl *TestLogger) Output() string

Output returns String returns the contents of the unread portion of the log output as a string.

func (*TestLogger) Printf added in v0.14.0

func (l *TestLogger) Printf(format string, v ...any)

func (*TestLogger) Println

func (l *TestLogger) Println(msg string, attrs ...slog.Attr)

func (*TestLogger) SetLevel

func (l *TestLogger) SetLevel(lvl Level)

func (*TestLogger) SystemDebug

func (l *TestLogger) SystemDebug(msg string, attrs ...slog.Attr)

func (*TestLogger) Warn

func (l *TestLogger) Warn(msg string, attrs ...slog.Attr)

Jump to

Keyboard shortcuts

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