zap

package
v0.0.6-rc.5 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CLIConfig

func CLIConfig(level log.Level) zap.Config

CLIConfig returns zap config for cli logging (custom cli encoder)

func ConsoleConfig

func ConsoleConfig(level log.Level) zap.Config

ConsoleConfig returns zap config for logging to console (zap's console encoder)

func Context

func Context(ctx context.Context) zap.Field

Context creates a log field from context - all fields bound with ctxlog.WithFields will be added.

func JSONConfig

func JSONConfig(level log.Level) zap.Config

JSONConfig returns zap config for structured logging (zap's json encoder)

func KVConfig

func KVConfig(level log.Level) zap.Config

KVConfig returns zap config for logging to kv (custom kv encoder)

func NewDeployConfig

func NewDeployConfig(opts ...cfgOption) zap.Config

NewDeployConfig returns default configuration (with no sampling). Not recommended for production use.

func NewDeployEncoderConfig

func NewDeployEncoderConfig() zapcore.EncoderConfig

NewDeployEncoderConfig returns an opinionated EncoderConfig for deploy environment.

func NewProductionDeployConfig

func NewProductionDeployConfig() zap.Config

NewProductionDeployConfig returns configuration, suitable for production use.

It uses a JSON encoder, writes to standard error, and enables sampling. Stacktraces are automatically included on logs of ErrorLevel and above.

func SetOutputPaths

func SetOutputPaths(paths []string) cfgOption

SetOutputPaths sets OutputPaths (stdout by default)

func StandardConfig

func StandardConfig(encoding string, level log.Level) zap.Config

StandardConfig returns default zap config with specified encoding and level

func TSKVConfig

func TSKVConfig(level log.Level) zap.Config

TSKVConfig returns zap config for logging to tskv (custom tskv encoder)

func UnzapifyLevel

func UnzapifyLevel(level zapcore.Level) log.Level

UnzapifyLevel turns zap log level to interface log level.

func WithDevelopment

func WithDevelopment(enabled bool) cfgOption

WithDevelopment sets Development option of zap.Config

func WithLevel

func WithLevel(level log.Level) cfgOption

WithLevel sets level of logging

func WithSampling

func WithSampling(initial int, thereafter int) cfgOption

WithSampling sets sampling settings initial and thereafter

func ZapifyLevel

func ZapifyLevel(level log.Level) zapcore.Level

ZapifyLevel turns interface log level to zap log level

Types

type Logger

type Logger struct {
	L *zap.Logger
}

Logger implements log.Logger interface

func Must

func Must(cfg zap.Config) *Logger

Must constructs zap-based logger from provided config and panics on error

func New

func New(cfg zap.Config) (*Logger, error)

New constructs zap-based logger from provided config

func NewCustomDeployLogger

func NewCustomDeployLogger(cfg zap.Config, opts ...zap.Option) (*Logger, error)

NewCustomDeployLogger constructs new logger by config cfg

func NewDeployLogger

func NewDeployLogger(level log.Level, opts ...zap.Option) (*Logger, error)

NewDeployLogger constructs fully-fledged Deploy compatible logger based on predefined config. See https://deploy.yandex-team.ru/docs/concepts/pod/sidecars/logs/logs#format for more information

func NewProductionDeployLogger

func NewProductionDeployLogger(level log.Level, opts ...zap.Option) (*Logger, error)

Same as NewDeployLogger, but with sampling

func NewQloudLogger

func NewQloudLogger(level log.Level, opts ...zap.Option) (*Logger, error)

NewQloudLogger constructs fully-fledged Qloud compatible logger based on predefined config. See https://wiki.yandex-team.ru/qloud/doc/logs for more information

func NewWithCore

func NewWithCore(core zapcore.Core, options ...zap.Option) *Logger

NewWithCore constructs zap-based logger from provided core

func (*Logger) AddCallerSkip

func (l *Logger) AddCallerSkip(skip int) log.Logger

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...log.Field)

Debug logs at Debug log level using fields

func (*Logger) Debugf

func (l *Logger) Debugf(msg string, args ...interface{})

Debugf logs at Debug log level using fmt formatter

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...log.Field)

Error logs at Error log level using fields

func (*Logger) Errorf

func (l *Logger) Errorf(msg string, args ...interface{})

Errorf logs at Error log level using fmt formatter

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, fields ...log.Field)

Fatal logs at Fatal log level using fields

func (*Logger) Fatalf

func (l *Logger) Fatalf(msg string, args ...interface{})

Fatalf logs at Fatal log level using fmt formatter

func (*Logger) Fmt

func (l *Logger) Fmt() log.Fmt

Fmt returns fmt logger

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...log.Field)

Info logs at Info log level using fields

func (*Logger) Infof

func (l *Logger) Infof(msg string, args ...interface{})

Infof logs at Info log level using fmt formatter

func (*Logger) Logger

func (l *Logger) Logger() log.Logger

Logger returns general logger

func (*Logger) Structured

func (l *Logger) Structured() log.Structured

Structured returns structured logger

func (*Logger) Trace

func (l *Logger) Trace(msg string, fields ...log.Field)

Trace logs at Trace log level using fields

func (*Logger) Tracef

func (l *Logger) Tracef(msg string, args ...interface{})

Tracef logs at Trace log level using fmt formatter

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields ...log.Field)

Warn logs at Warn log level using fields

func (*Logger) Warnf

func (l *Logger) Warnf(msg string, args ...interface{})

Warnf logs at Warn log level using fmt formatter

func (*Logger) With

func (l *Logger) With(fields ...log.Field) log.Logger

With returns logger that always adds provided key/value to every log entry

func (*Logger) WithName

func (l *Logger) WithName(name string) log.Logger

WithName adds name to logger

Directories

Path Synopsis
Package asynczap implements asynchronous core for zap.
Package asynczap implements asynchronous core for zap.

Jump to

Keyboard shortcuts

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