logx

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelDebug  slog.Level = slog.LevelDebug
	LevelInfo   slog.Level = slog.LevelInfo
	LevelWarn   slog.Level = slog.LevelWarn
	LevelError  slog.Level = slog.LevelError
	LevelSilent slog.Level = math.MaxInt
)

Variables

This section is empty.

Functions

func Close

func Close() error

func DebugContext

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

func DefaultLevel

func DefaultLevel() slog.Level

func DefaultLeveler

func DefaultLeveler() slog.Leveler

func DefaultOutput

func DefaultOutput() io.Writer

func ErrorContext

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

func FatalContext

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

func GetContextArgs

func GetContextArgs(ctx context.Context, args ...string) []any

func GetEventBaseId

func GetEventBaseId(ctx context.Context) string

func GetEventId

func GetEventId(ctx context.Context) string

func GetEventLastId

func GetEventLastId(ctx context.Context) string

func GetLevel

func GetLevel(ctx context.Context) slog.Level

func GetName

func GetName(ctx context.Context) string

func GetValue

func GetValue(ctx context.Context, key string) any

func GetValues

func GetValues(ctx context.Context) map[string]any

func GetValuesAny

func GetValuesAny(ctx context.Context) any

func InfoContext

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

func MakeEventId

func MakeEventId(event string) string

func ParseFormat

func ParseFormat(args ...string) (int, error)

func ParseLevel

func ParseLevel(args ...string) (int, error)

func ParseOutput

func ParseOutput(args ...string) (int, error)

func RegisterContextAnyArg

func RegisterContextAnyArg[T any](arg string, getter func(context.Context) T)

func RegisterContextNonZeroArg

func RegisterContextNonZeroArg[T comparable](arg string, getter func(context.Context) T)

func SetDefault

func SetDefault(logger Logger)

func SetDefaultLevel

func SetDefaultLevel(level slog.Level)

func SetDefaultOutput

func SetDefaultOutput(output io.Writer)

func SetEvent

func SetEvent(ctx context.Context, event string) context.Context

func SetEventId

func SetEventId(ctx context.Context, eventId string) context.Context

func SetName

func SetName(ctx context.Context, name string) context.Context

func UnregisterContextArg

func UnregisterContextArg(arg string)

func WarnContext

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

func WithEvent

func WithEvent(ctx context.Context, event string) context.Context

func WithEventId

func WithEventId(ctx context.Context, eventId string) context.Context

func WithLevel

func WithLevel(ctx context.Context, level slog.Level) context.Context

func WithLogger

func WithLogger(ctx context.Context, logger Logger) context.Context

func WithName

func WithName(ctx context.Context, name string) context.Context

func WithValue

func WithValue(ctx context.Context, key string, value any) context.Context

func WrapLevelHandler

func WrapLevelHandler(handler slog.Handler) slog.Handler

Types

type Logger

type Logger interface {
	DebugContext(ctx context.Context, msg string, args ...any)
	InfoContext(ctx context.Context, msg string, args ...any)
	WarnContext(ctx context.Context, msg string, args ...any)
	ErrorContext(ctx context.Context, msg string, args ...any)
}

func Default

func Default() Logger

func GetLogger

func GetLogger(ctx context.Context) Logger

func NewJsonLogger

func NewJsonLogger(args ...string) Logger

func NewTextLogger

func NewTextLogger(args ...string) Logger

func WrapLogger

func WrapLogger(logger Logger, args ...string) Logger

Jump to

Keyboard shortcuts

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