logutils

package module
v0.0.0-...-b592c64 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelTrace     = slog.Level(-8)
	LevelTraceName = "TRACE"
)
View Source
const (
	JSON = "json"
	TEXT = "text"
)
View Source
const (
	ERROR = "error"
)

Variables

This section is empty.

Functions

func ErrDebug

func ErrDebug(msg string, err error, additional ...slog.Attr)

func ErrError

func ErrError(msg string, err error, additional ...slog.Attr)

func ErrInfo

func ErrInfo(msg string, err error, additional ...slog.Attr)

func ErrLog

func ErrLog(level slog.Level, msg string, err error, additional ...slog.Attr)

func ErrTrace

func ErrTrace(msg string, err error, additional ...slog.Attr)

func ErrWarn

func ErrWarn(msg string, err error, additional ...slog.Attr)

func NewDefaultLogger

func NewDefaultLogger(loglevel string, format Format)

func ReplaceLogLevel

func ReplaceLogLevel(groups []string, a slog.Attr) slog.Attr

func ReplaceSource

func ReplaceSource(groups []string, a slog.Attr) slog.Attr

func SetDefaultErrorer

func SetDefaultErrorer(format Format)

Types

type Errorer

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

func NewErrorer

func NewErrorer(attrs ...slog.Attr) *Errorer

func (*Errorer) Error

func (e *Errorer) Error(err error, additional ...slog.Attr) error

type Format

type Format string

type Logger

type Logger struct {
	*slog.Logger
}

func DefaultLogger

func DefaultLogger() *Logger

func NewLoggerFromDefault

func NewLoggerFromDefault(options *slog.HandlerOptions, format Format) *Logger

func (*Logger) Trace

func (l *Logger) Trace(msg string, additional ...slog.Attr)

func (*Logger) With

func (l *Logger) With(args ...slog.Attr) *Logger

type StructuredError

type StructuredError struct {
	Attrs []slog.Attr
	Err   error
}

func NewStructuredError

func NewStructuredError(err error, attrs ...slog.Attr) StructuredError

func (StructuredError) Error

func (serr StructuredError) Error() string

func (StructuredError) Unwrap

func (serr StructuredError) Unwrap() error

Jump to

Keyboard shortcuts

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