log

package
v0.0.0-...-c943480 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// default to text loggging format
	LogFormatText = iota
	LogFormatJSON = iota

	// slog levels are based off OpenTelemetry
	// OpenTelemetry levels: https://opentelemetry.io/docs/specs/otel/logs/data-model/#field-severitynumber
	// log/slog levels: https://cs.opensource.google/go/x/exp/+/d852ddb8:slog/level.go
	LevelTrace      = slog.Level(-8)
	LevelTraceLabel = "TRACE"
	LevelTraceName  = "DEBUG-4"
	LevelFatal      = slog.Level(12)
	LevelFatalLabel = "FATAL"
	LevelFatalName  = "ERROR+4"
)

Variables

This section is empty.

Functions

func LogFormats

func LogFormats() []string

func LogLevel

func LogLevel(level string) (slog.Level, error)

func LogLevels

func LogLevels() []string

Types

type Format

type Format int

func LogFormat

func LogFormat(format string) Format

type Log

type Log struct {
	*slog.Logger
	Format
}

func NewLog

func NewLog() *Log

func NewLogWithOptions

func NewLogWithOptions(options Options) *Log

func (*Log) Debugf

func (log *Log) Debugf(format string, args ...any)

func (*Log) Errorf

func (log *Log) Errorf(format string, args ...any)

func (*Log) Fatalf

func (log *Log) Fatalf(format string, args ...any)

func (*Log) Infof

func (log *Log) Infof(format string, args ...any)

func (*Log) Tracef

func (log *Log) Tracef(format string, args ...any)

func (*Log) Warnf

func (log *Log) Warnf(format string, args ...any)

func (*Log) WithError

func (log *Log) WithError(err error) *Log

type Options

type Options struct {
	Conf        *koanf.Koanf
	AddSource   bool
	Level       slog.Leveler
	ReplaceAttr func(groups []string, a slog.Attr) slog.Attr
	// LOG_FORMAT supports either text (default) or json
	Format Format
	// log output defaults to os.Stdout
	Out io.Writer
}

drop-in for slog.HandlerOptions

func DefaultOptions

func DefaultOptions() Options

Jump to

Keyboard shortcuts

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