slog

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

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

Debug logs a line with level debug.

func Debugf

func Debugf(format string, args ...any)

Debugf logs a format line with level debug.

func DefaultLogger added in v1.5.0

func DefaultLogger() log.Logger

DefaultLogger returns the default instance of logfmt logger

func Error

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

Error logs a line with level error. If err is not nil it adds only the msg string or vice-versa. Otherwise adds both.

func Errorf

func Errorf(err error, format string, args ...any)

Errorf logs a format line with level error. If err is not nil it adds only the msg string or vice-versa. Otherwise adds both.

func Info

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

Info logs a line with level Info.

func Infof

func Infof(format string, args ...any)

Infof logs a format line with level info.

func Warn

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

Warn logs a line with level warn.

func Warnf

func Warnf(format string, args ...any)

Warnf logs a format line with level warn.

Types

type Logger added in v1.5.0

type Logger interface {
	Info(msg string, args ...any)
	Warn(msg string, args ...any)
	Debug(msg string, args ...any)
	Error(err error, msg string, args ...any)
	Infof(format string, args ...any)
	Warnf(format string, args ...any)
	Debugf(format string, args ...any)
	Errorf(err error, format string, args ...any)
	WithTraceId(ctx context.Context) Logger
	WithFields(fields map[string]any) Logger
}

Logger represents the methods supported by slog

func NewLogger added in v1.5.0

func NewLogger() Logger

NewLogger returns a new instance of Logger.

func WithFields

func WithFields(fields map[string]any) Logger

WithFields returns WithFields using the defaultLoggerWrapper.

func WithTraceId

func WithTraceId(ctx context.Context) Logger

WithTraceId returns WithTraceId using the defaultLoggerWrapper.

Jump to

Keyboard shortcuts

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