ctx_log

package
v0.0.0-...-8943b3e Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogger

func SetLogger(config *Config) error

TODO: initLogging

Types

type Config

type Config struct {
	JSON         bool
	Level        Level
	StaticFields map[string]string

	MessageField *string
	LevelField   *string
	TimeField    *string
	CallerField  *string
	ModuleField  *string
}

type ContextLogger

type ContextLogger interface {
	WithCtxFields(ctx context.Context) ContextLogger
	SetCtxField(ctx context.Context, key string, value string) context.Context

	IsEnabledFor(level Level) bool

	Trace(args ...interface{})
	Tracef(msg string, args ...interface{})
	Debug(args ...interface{})
	Debugf(msg string, args ...interface{})
	Info(args ...interface{})
	Infof(msg string, args ...interface{})
	Warn(args ...interface{})
	Warnf(msg string, args ...interface{})
	Error(args ...interface{})
	Errorf(msg string, args ...interface{})
	//      TODO: WithPanic
	Panic(args ...interface{})
	Panicf(msg string, args ...interface{})
	Fatal(args ...interface{})
	Fatalf(msg string, args ...interface{})

	WithField(key string, value string) ContextLogger
	WithError(err error) ContextLogger

	SkipCallers(count int) ContextLogger
}

func GetLogger

func GetLogger(module interface{}) ContextLogger

type CtxFields

type CtxFields []zapcore.Field

type Level

type Level uint
const (
	TraceLevel Level = iota
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel
	// InfoLevel level. General operational entries about what's going on inside the
	// application.
	InfoLevel
	// WarnLevel level. Non-critical entries that deserve eyes.
	WarnLevel
	// ErrorLevel level. Logs. Used for errors that should definitely be noted.
	// Commonly used for hooks to send errors to an error tracking service.
	ErrorLevel
	// PanicLevel level, highest level of severity. Logs and then calls panic with the
	// message passed to Debug, Info, ...
	PanicLevel
	// FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the
	// logging level is set to Panic.
	FatalLevel
)

func Text2Level

func Text2Level(level string) Level

Jump to

Keyboard shortcuts

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