logger

package module
v0.0.0-...-92e43b2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithKV

func ContextWithKV(ctx context.Context, kvs ...interface{}) context.Context

ContextWithKV returns new context with specified logger with field

func ContextWithTags

func ContextWithTags(ctx context.Context, tags ...string) context.Context

func Debug

func Debug(ctx context.Context, args ...interface{})

func DebugKV

func DebugKV(ctx context.Context, message string, kvs ...interface{})

func Debugf

func Debugf(ctx context.Context, format string, args ...interface{})

func Error

func Error(ctx context.Context, args ...interface{})

func ErrorKV

func ErrorKV(ctx context.Context, message string, kvs ...interface{})

func Errorf

func Errorf(ctx context.Context, format string, args ...interface{})

func Fatal

func Fatal(ctx context.Context, args ...interface{})

func FatalKV

func FatalKV(ctx context.Context, message string, kvs ...interface{})

func Fatalf

func Fatalf(ctx context.Context, format string, args ...interface{})

func FromContext

func FromContext(ctx context.Context) *zap.SugaredLogger

FromContext returns logger from context if set. Otherwise returns global `global` logger. In both cases returned logger is populated with `trace_id` & `span_id`.

func Info

func Info(ctx context.Context, args ...interface{})

func InfoKV

func InfoKV(ctx context.Context, message string, kvs ...interface{})

func Infof

func Infof(ctx context.Context, format string, args ...interface{})

func InitLogger

func InitLogger(prefix, version string) error

func Logger

func Logger() *zap.SugaredLogger

Logger returns current global logger.

func New

func New(lvl zapcore.LevelEnabler, cfg *Config, options ...zap.Option) *zap.SugaredLogger

New creates new *zap.SugaredLogger with standard EncoderConfig

func SetLogger

func SetLogger(l *zap.SugaredLogger)

SetLogger sets global used logger. This function is not thread-safe.

func ToContext

func ToContext(ctx context.Context, l *zap.SugaredLogger) context.Context

ToContext returns new context with specified sugared logger inside.

func Warn

func Warn(ctx context.Context, args ...interface{})

func WarnKV

func WarnKV(ctx context.Context, message string, kvs ...interface{})

func Warnf

func Warnf(ctx context.Context, format string, args ...interface{})

func WatchAndRebuildLogger

func WatchAndRebuildLogger(ctx context.Context, prefix, version string, cfg *Config, w watcher)

func WithLevel

func WithLevel(lvl zapcore.Level) zap.Option

WithLevel returns `zap.Option` that can be used to create a new logger from an existing one with a new logging level

Usage:

logger.Logger().Desugar().WithOptions(logger.WithLevel(level)).Sugar()

Types

type Config

type Config struct {
	LogLevel   string `envconfig:"default=info"`
	MessageKey string `envconfig:"default=message"`
	LevelKey   string `envconfig:"default=level"`
	TimeKey    string `envconfig:"default=timestamp"`
	AppName    string `envconfig:"default=app"`
	Host       string `envconfig:"default=localhost"`
	Version    string `envconfig:"default=0.0.0"`
	DevMode    bool   `envconfig:"default=false"`
}

Jump to

Keyboard shortcuts

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