log

package
v0.1.7-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, args ...any)

func DebugContext

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

func Enabled

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

func Error

func Error(msg string, args ...any)

func ErrorContext

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

func Handler

func Handler() slog.Handler

func Info

func Info(msg string, args ...any)

func InfoContext

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

func Init

func Init(opts ...Option)

func InitDefaultLogger

func InitDefaultLogger()

func Log

func Log(ctx context.Context, level slog.Level, msg string, args ...any)

func LogAttrs

func LogAttrs(ctx context.Context, level slog.Level, msg string, attrs ...slog.Attr)

func Panic

func Panic(msg string, args ...any)

func PanicContext

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

func Warn

func Warn(msg string, args ...any)

func WarnContext

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

func WithJSON

func WithJSON(c *Config)

func WithSource

func WithSource(c *Config)

Types

type Config

type Config struct {
	slog.HandlerOptions
	// contains filtered or unexported fields
}

type Logger

type Logger interface {
	Handler() slog.Handler
	With(args ...any) Logger
	WithGroup(name string) Logger
	Enabled(ctx context.Context, level slog.Level) bool
	Log(ctx context.Context, level slog.Level, msg string, args ...any)
	LogAttrs(ctx context.Context, level slog.Level, msg string, attrs ...slog.Attr)
	Debug(msg string, args ...any)
	DebugContext(ctx context.Context, msg string, args ...any)
	Info(msg string, args ...any)
	InfoContext(ctx context.Context, msg string, args ...any)
	Warn(msg string, args ...any)
	WarnContext(ctx context.Context, msg string, args ...any)
	Error(msg string, args ...any)
	ErrorContext(ctx context.Context, msg string, args ...any)
	Panic(msg string, args ...any)
	PanicContext(ctx context.Context, msg string, args ...any)
}

func New

func New(opts ...Option) (l Logger)

func NewDefaultLogger

func NewDefaultLogger() Logger

func With

func With(args ...any) Logger

func WithGroup

func WithGroup(name string) Logger

type Option

type Option func(c *Config)

func WithLevel

func WithLevel(lvl slog.Leveler) Option

func WithLevelListener

func WithLevelListener(listener func() slog.Level, tick time.Duration) Option

func WithPrefix

func WithPrefix(prefix string) Option

func WithReplaceAttr

func WithReplaceAttr(repl ...func(groups []string, a slog.Attr) slog.Attr) Option

func WithTimeFormat

func WithTimeFormat(format string) Option

func WithWriter

func WithWriter(w io.Writer) Option

Jump to

Keyboard shortcuts

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