Documentation ¶
Index ¶
- func ContextWithKV(ctx context.Context, kvs ...interface{}) context.Context
- func ContextWithTags(ctx context.Context, tags ...string) context.Context
- func Debug(ctx context.Context, args ...interface{})
- func DebugKV(ctx context.Context, message string, kvs ...interface{})
- func Debugf(ctx context.Context, format string, args ...interface{})
- func Error(ctx context.Context, args ...interface{})
- func ErrorKV(ctx context.Context, message string, kvs ...interface{})
- func Errorf(ctx context.Context, format string, args ...interface{})
- func Fatal(ctx context.Context, args ...interface{})
- func FatalKV(ctx context.Context, message string, kvs ...interface{})
- func Fatalf(ctx context.Context, format string, args ...interface{})
- func FromContext(ctx context.Context) *zap.SugaredLogger
- func Info(ctx context.Context, args ...interface{})
- func InfoKV(ctx context.Context, message string, kvs ...interface{})
- func Infof(ctx context.Context, format string, args ...interface{})
- func InitLogger(prefix, version string) error
- func Logger() *zap.SugaredLogger
- func New(lvl zapcore.LevelEnabler, cfg *Config, options ...zap.Option) *zap.SugaredLogger
- func SetLogger(l *zap.SugaredLogger)
- func ToContext(ctx context.Context, l *zap.SugaredLogger) context.Context
- func Warn(ctx context.Context, args ...interface{})
- func WarnKV(ctx context.Context, message string, kvs ...interface{})
- func Warnf(ctx context.Context, format string, args ...interface{})
- func WatchAndRebuildLogger(ctx context.Context, prefix, version string, cfg *Config, w watcher)
- func WithLevel(lvl zapcore.Level) zap.Option
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithKV ¶
ContextWithKV returns new context with specified logger with field
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 InitLogger ¶
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 WatchAndRebuildLogger ¶
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"` }
Click to show internal directories.
Click to hide internal directories.