Documentation
¶
Index ¶
- func FormatStrings() []string
- func LevelStrings() []string
- func NewStdLog(log *Logger) *stdLog.Logger
- type Attr
- func Any(key string, v any) Attr
- func Bool(key string, v bool) Attr
- func Duration(key string, v time.Duration) Attr
- func Error(err error) Attr
- func Float64(key string, v float64) Attr
- func Int(key string, value int) Attr
- func Int64(key string, value int64) Attr
- func String(key, value string) Attr
- func Strings(key string, value ...string) Attr
- func Time(key string, v time.Time) Attr
- func Uint16(key string, v uint16) Attr
- func Uint64(key string, v uint64) Attr
- type Format
- type Level
- type Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatStrings ¶
func FormatStrings() []string
FormatStrings returns a slice of all logging formats as strings.
func LevelStrings ¶
func LevelStrings() []string
LevelStrings returns a slice of all logging levels as strings.
Types ¶
type Attr ¶
An Attr is a key-value pair.
func Duration ¶
Duration returns an Attr for a time.Duration.
type Format ¶
type Format uint8
A Format is a logging format.
func ParseFormat ¶
ParseFormat parses a format (case is ignored) based on the ASCII representation of the log format. If the provided ASCII representation is invalid an error is returned.
This is particularly useful when dealing with text input to configure log formats.
type Level ¶
type Level int8
A Level is a logging level.
func ParseLevel ¶
ParseLevel parses a level (case is ignored) based on the ASCII representation of the log level. If the provided ASCII representation is invalid an error is returned.
This is particularly useful when dealing with text input to configure log levels.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a simple logger that wraps slog.Logger. It provides a more convenient API for logging and formatting messages.
func New ¶
New creates a new logger with the given level and format. Optionally, you can specify the writer to write logs to.
func NewNop ¶
func NewNop() *Logger
NewNop returns a no-op Logger. It never writes out logs or internal errors. The common use case is to use it in tests.