log

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelTrace slog.Level = -8
	LevelDebug            = slog.LevelDebug
	LevelInfo             = slog.LevelInfo
	LevelWarn             = slog.LevelWarn
	LevelError            = slog.LevelError
	LevelCrit  slog.Level = 12

	LvlTrace = LevelTrace
	LvlInfo  = LevelInfo
	LvlDebug = LevelDebug
)

Variables

This section is empty.

Functions

func Crit

func Crit(msg string, ctx ...interface{})

func Debug

func Debug(msg string, ctx ...interface{})

func DiscardHandler

func DiscardHandler() slog.Handler

func Error

func Error(msg string, ctx ...interface{})

func FormatLogfmtUint64

func FormatLogfmtUint64(n uint64) string

func FormatSlogValue

func FormatSlogValue(v slog.Value, tmp []byte) (result []byte)

func FromLegacyLevel

func FromLegacyLevel(lvl int) slog.Level

func Info

func Info(msg string, ctx ...interface{})

func JSONHandler

func JSONHandler(wr io.Writer) slog.Handler

func JSONHandlerWithLevel

func JSONHandlerWithLevel(wr io.Writer, level slog.Level) slog.Handler

func LevelAlignedString

func LevelAlignedString(l slog.Level) string

func LevelString

func LevelString(l slog.Level) string

func LogfmtHandler

func LogfmtHandler(wr io.Writer) slog.Handler

func LogfmtHandlerWithLevel

func LogfmtHandlerWithLevel(wr io.Writer, level slog.Level) slog.Handler

func SetDefault

func SetDefault(l Logger)

func StirngLevel

func StirngLevel(lvl string) slog.Level

func Trace

func Trace(msg string, ctx ...interface{})

func Warn

func Warn(msg string, ctx ...interface{})

Types

type GlogHandler

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

func NewGlogHandler

func NewGlogHandler(h slog.Handler) *GlogHandler

func (*GlogHandler) Enabled

func (h *GlogHandler) Enabled(_ context.Context, lvl slog.Level) bool

func (*GlogHandler) Handle

func (h *GlogHandler) Handle(_ context.Context, r slog.Record) error

func (*GlogHandler) Verbosity

func (h *GlogHandler) Verbosity(level slog.Level)

func (*GlogHandler) Vmodule

func (h *GlogHandler) Vmodule(ruleset string) error

func (*GlogHandler) WithAttrs

func (h *GlogHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*GlogHandler) WithGroup

func (h *GlogHandler) WithGroup(name string) slog.Handler

type Logger

type Logger interface {
	With(ctx ...interface{}) Logger
	New(ctx ...interface{}) Logger
	Log(level slog.Level, msg string, ctx ...interface{})
	Trace(msg string, ctx ...interface{})
	Debug(msg string, ctx ...interface{})
	Info(msg string, ctx ...interface{})
	Warn(msg string, ctx ...interface{})
	Error(msg string, ctx ...interface{})
	Crit(msg string, ctx ...interface{})
	Write(level slog.Level, msg string, attrs ...any)
	Enabled(ctx context.Context, level slog.Level) bool
	Handler() slog.Handler
}

func New

func New(ctx ...interface{}) Logger

func NewLogger

func NewLogger(h slog.Handler) Logger

func Root

func Root() Logger

type TerminalHandler

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

func NewTerminalHandler

func NewTerminalHandler(wr io.Writer, useColor bool) *TerminalHandler

func NewTerminalHandlerWithLevel

func NewTerminalHandlerWithLevel(wr io.Writer, lvl slog.Level, useColor bool) *TerminalHandler

func (*TerminalHandler) Enabled

func (h *TerminalHandler) Enabled(_ context.Context, level slog.Level) bool

func (*TerminalHandler) Handle

func (h *TerminalHandler) Handle(_ context.Context, r slog.Record) error

func (*TerminalHandler) ResetFieldPadding

func (h *TerminalHandler) ResetFieldPadding()

func (*TerminalHandler) WithAttrs

func (h *TerminalHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*TerminalHandler) WithGroup

func (h *TerminalHandler) WithGroup(name string) slog.Handler

type TerminalStringer

type TerminalStringer interface {
	TerminalString() string
}

Jump to

Keyboard shortcuts

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