Documentation ¶
Index ¶
- func CtxGetFields(ctx context.Context) (fields []zap.Field)
- func CtxWithFields(ctx context.Context, fields ...zap.Field) context.Context
- func Default() *zap.Logger
- func NewNamedSugared(name string) *zap.SugaredLogger
- func SetDefault(l *zap.Logger)
- func SetNamedLevels(nls []NamedLevel)
- func WithCtx(ctx context.Context, l *zap.Logger) *zap.Logger
- type Config
- type CtxLogger
- func (cl CtxLogger) DebugCtx(ctx context.Context, msg string, fields ...zap.Field)
- func (cl CtxLogger) ErrorCtx(ctx context.Context, msg string, fields ...zap.Field)
- func (cl CtxLogger) InfoCtx(ctx context.Context, msg string, fields ...zap.Field)
- func (cl CtxLogger) Sugar() *zap.SugaredLogger
- func (cl CtxLogger) WarnCtx(ctx context.Context, msg string, fields ...zap.Field)
- func (cl CtxLogger) With(fields ...zap.Field) CtxLogger
- type LogFormat
- type NamedLevel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewNamedSugared ¶
func NewNamedSugared(name string) *zap.SugaredLogger
func SetDefault ¶
SetDefault replaces the default logger you need to call SetNamedLevels after in case you have named loggers, otherwise they will use the old logger
func SetNamedLevels ¶
func SetNamedLevels(nls []NamedLevel)
SetNamedLevels sets the namedLevels for named loggers it also supports glob patterns for names, like "app*" can be racy in case there are existing named loggers so consider to call only once at the beginning
Types ¶
type Config ¶
type Config struct { Production bool `yaml:"production"` DefaultLevel string `yaml:"defaultLevel"` Levels []NamedLevel `yaml:"levels"` // first match will be used AddOutputPaths []string `yaml:"outputPaths"` DisableStdErr bool `yaml:"disableStdErr"` Format LogFormat `yaml:"format"` ZapConfig *zap.Config `yaml:"-"` // optional, if set it will be used instead of other config options }
func (Config) ApplyGlobal ¶
func (l Config) ApplyGlobal()
type CtxLogger ¶
func (CtxLogger) Sugar ¶
func (cl CtxLogger) Sugar() *zap.SugaredLogger
type NamedLevel ¶
func LevelsFromStr ¶
func LevelsFromStr(s string) (levels []NamedLevel)
LevelsFromStr parses a string of the form "name1=DEBUG;prefix*=WARN;*=ERROR" into a slice of NamedLevel it may be useful to parse the log level from the OS env var
Click to show internal directories.
Click to hide internal directories.