logger

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelTrace = slog.Level(-8)
	LevelFatal = slog.Level(12)
)
View Source
const (
	EnvLogFormat = "LOG_FORMAT"
	EnvLogLevel  = "LOG_LEVEL"
)
View Source
const (
	LogFormatJson = "json"
	LogFormatText = "text"
)

Variables

View Source
var LevelMap = invertMap(LevelNames)
View Source
var LevelNames = map[slog.Leveler]string{
	LevelTrace: "TRACE",
	LevelFatal: "FATAL",
}

Functions

func InitInstance

func InitInstance(config LogConfig)

Types

type LogConfig

type LogConfig struct {
	Format string `env:"LOG_FORMAT" enum:"json, text" default:"text" help:"Log format. One of: [json, text]"`
	Level  string `` /* 129-byte string literal not displayed */
}

type Logger

type Logger struct {
	*slog.Logger
}

func GetInstance

func GetInstance() *Logger

func NewDefaultLogger

func NewDefaultLogger() *Logger

func NewLogger

func NewLogger(config LogConfig) *Logger

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...any)

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...any)

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, args ...any)

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, args ...any)

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...any)

func (*Logger) IsLevelEnabled

func (l *Logger) IsLevelEnabled(level slog.Level) bool

func (*Logger) Trace

func (l *Logger) Trace(msg string, args ...any)

func (*Logger) Tracef

func (l *Logger) Tracef(format string, args ...any)

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...any)

func (*Logger) With

func (l *Logger) With(args ...any) *Logger

func (*Logger) WithFields

func (l *Logger) WithFields(fields map[string]any) *Logger

Jump to

Keyboard shortcuts

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