Documentation
¶
Index ¶
- Variables
- func FromContext(ctx context.Context) *zap.Logger
- func Of(ctx context.Context) *zap.Logger
- func SetDebugDefaults()
- func WithLogger(ctx context.Context, logger *zap.Logger) context.Context
- func WithNewEnvLogger(ctx context.Context, builders ...BuilderFunc) (context.Context, error)
- func WithNewEnvLoggerForced(ctx context.Context, builders ...BuilderFunc) context.Context
- func WithNewLogger(ctx context.Context, builders ...BuilderFunc) (context.Context, error)
- func WithNewLoggerForced(ctx context.Context, builders ...BuilderFunc) context.Context
- type Builder
- func (b *Builder) AddErrorOutputPath(path string) *Builder
- func (b *Builder) AddHook(hook func(zapcore.Entry) error) *Builder
- func (b *Builder) AddInitialField(key string, value interface{}) *Builder
- func (b *Builder) AddOutputPath(path string) *Builder
- func (b *Builder) Build() (*zap.Logger, error)
- func (b *Builder) CallerKey(key string) *Builder
- func (b *Builder) CapitalLevel() *Builder
- func (b *Builder) ColorLevel() *Builder
- func (b *Builder) ConsoleEncoding() *Builder
- func (b *Builder) CustomTime(layout string) *Builder
- func (b *Builder) Development(dev bool) *Builder
- func (b *Builder) DisableCaller(disable bool) *Builder
- func (b *Builder) DisableStacktrace(disable bool) *Builder
- func (b *Builder) EncodeCaller(encoder zapcore.CallerEncoder) *Builder
- func (b *Builder) EncodeDuration(encoder zapcore.DurationEncoder) *Builder
- func (b *Builder) EncodeLevel(encoder zapcore.LevelEncoder) *Builder
- func (b *Builder) EncodeTime(encoder zapcore.TimeEncoder) *Builder
- func (b *Builder) Encoding(encoding string) *Builder
- func (b *Builder) Environment(env string) *Builder
- func (b *Builder) EpochTime() *Builder
- func (b *Builder) ErrorOutputPaths(paths ...string) *Builder
- func (b *Builder) FromEnv() *Builder
- func (b *Builder) FullCaller() *Builder
- func (b *Builder) ISO8601Time() *Builder
- func (b *Builder) InitialFields(fields map[string]interface{}) *Builder
- func (b *Builder) JSONEncoding() *Builder
- func (b *Builder) Level(level string) *Builder
- func (b *Builder) LevelKey(key string) *Builder
- func (b *Builder) LevelValue(level zapcore.Level) *Builder
- func (b *Builder) LineEnding(ending string) *Builder
- func (b *Builder) LowercaseLevel() *Builder
- func (b *Builder) MessageKey(key string) *Builder
- func (b *Builder) MustBuild() *zap.Logger
- func (b *Builder) Name(name string) *Builder
- func (b *Builder) NameKey(key string) *Builder
- func (b *Builder) NanosDuration() *Builder
- func (b *Builder) NoSampling() *Builder
- func (b *Builder) OutputPaths(paths ...string) *Builder
- func (b *Builder) RFC3339Time() *Builder
- func (b *Builder) Sampling(initial int, thereafter int) *Builder
- func (b *Builder) SecondsDuration() *Builder
- func (b *Builder) ServiceName(name string) *Builder
- func (b *Builder) ShortCaller() *Builder
- func (b *Builder) Silent() *Builder
- func (b *Builder) StacktraceKey(key string) *Builder
- func (b *Builder) StringDuration() *Builder
- func (b *Builder) TimeKey(key string) *Builder
- func (b *Builder) Version(version string) *Builder
- type BuilderFunc
Constants ¶
This section is empty.
Variables ¶
var ( DefaultLevel = zapcore.InfoLevel DefaultFormat = zapcore.LowercaseLevelEncoder DefaultDevelopment = false DefaultSampling *zap.SamplingConfig = nil DefaultDebugSampling = 100 )
Functions ¶
func FromContext ¶
FromContext extracts logger from context, or returns a nop logger if it was not found.
func SetDebugDefaults ¶
func SetDebugDefaults()
func WithLogger ¶
WithLogger adds logger to context.
func WithNewEnvLogger ¶
WithNewEnvLogger builds logger using env variables and attach it to given context.
func WithNewEnvLoggerForced ¶
func WithNewEnvLoggerForced( ctx context.Context, builders ...BuilderFunc, ) context.Context
WithNewLoggerForced does what WithNewLogger does but panics if fails.
func WithNewLogger ¶
WithNewLogger builds logger and attach it to given context.
func WithNewLoggerForced ¶
func WithNewLoggerForced( ctx context.Context, builders ...BuilderFunc, ) context.Context
WithNewLoggerForced does what WithNewLogger does but panics if fails.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder provides a fluent interface for configuring zap logger.
func NewBuilder ¶
func NewBuilder() *Builder
NewBuilder creates a new LoggerBuilder with default values.
func (*Builder) AddErrorOutputPath ¶
AddErrorOutputPath adds an error output path.
func (*Builder) AddInitialField ¶
AddInitialField adds an initial field.
func (*Builder) AddOutputPath ¶
AddOutputPath adds an output path.
func (*Builder) CapitalLevel ¶
CapitalLevel sets capital level encoding.
func (*Builder) ColorLevel ¶
ColorLevel sets colored level encoding.
func (*Builder) ConsoleEncoding ¶
ConsoleEncoding sets console encoding.
func (*Builder) CustomTime ¶
CustomTime sets custom time encoding.
func (*Builder) Development ¶
Development enables/disables development mode (console logger).
func (*Builder) DisableCaller ¶
DisableCaller enables/disables caller information.
func (*Builder) DisableStacktrace ¶
DisableStacktrace enables/disables stacktrace.
func (*Builder) EncodeCaller ¶
func (b *Builder) EncodeCaller(encoder zapcore.CallerEncoder) *Builder
EncodeCaller sets the caller encoder.
func (*Builder) EncodeDuration ¶
func (b *Builder) EncodeDuration(encoder zapcore.DurationEncoder) *Builder
EncodeDuration sets the duration encoder.
func (*Builder) EncodeLevel ¶
func (b *Builder) EncodeLevel(encoder zapcore.LevelEncoder) *Builder
EncodeLevel sets the level encoder.
func (*Builder) EncodeTime ¶
func (b *Builder) EncodeTime(encoder zapcore.TimeEncoder) *Builder
EncodeTime sets the time encoder.
func (*Builder) Environment ¶
Environment adds environment to initial fields.
func (*Builder) ErrorOutputPaths ¶
ErrorOutputPaths sets the error output paths.
func (*Builder) FromEnv ¶
FromEnv configures the builder using environment variables with sane defaults.
func (*Builder) FullCaller ¶
FullCaller sets full caller encoding.
func (*Builder) ISO8601Time ¶
ISO8601Time sets ISO8601 time encoding.
func (*Builder) InitialFields ¶
InitialFields sets initial fields.
func (*Builder) JSONEncoding ¶
JSONEncoding sets JSON encoding.
func (*Builder) LevelValue ¶
LevelValue sets the logging level using zapcore.Level.
func (*Builder) LineEnding ¶
LineEnding sets the line ending.
func (*Builder) LowercaseLevel ¶
LowercaseLevel sets lowercase level encoding.
func (*Builder) MessageKey ¶
MessageKey sets the message field key.
func (*Builder) NanosDuration ¶
NanosDuration sets nanoseconds duration encoding.
func (*Builder) OutputPaths ¶
OutputPaths sets the output paths.
func (*Builder) RFC3339Time ¶
RFC3339Time sets RFC3339 time encoding.
func (*Builder) SecondsDuration ¶
SecondsDuration sets seconds duration encoding.
func (*Builder) ServiceName ¶
ServiceName adds service name to initial fields.
func (*Builder) ShortCaller ¶
ShortCaller sets short caller encoding.
func (*Builder) StacktraceKey ¶
StacktraceKey sets the stacktrace field key.
func (*Builder) StringDuration ¶
StringDuration sets string duration encoding.