MCPcopy
hub / github.com/uber-go/zap / NewProductionEncoderConfig

Function NewProductionEncoderConfig

config.go:124–139  ·  view source on GitHub ↗

NewProductionEncoderConfig returns an opinionated EncoderConfig for production environments. Messages encoded with this configuration will be JSON-formatted and will have the following keys by default: - "level": The logging level (e.g. "info", "error"). - "ts": The current time in number of secon

()

Source from the content-addressed store, hash-verified

122// cfg := zap.NewProductionEncoderConfig()
123// cfg.EncodeTime = zapcore.ISO8601TimeEncoder
124func NewProductionEncoderConfig() zapcore.EncoderConfig {
125 return zapcore.EncoderConfig{
126 TimeKey: "ts",
127 LevelKey: "level",
128 NameKey: "logger",
129 CallerKey: "caller",
130 FunctionKey: zapcore.OmitKey,
131 MessageKey: "msg",
132 StacktraceKey: "stacktrace",
133 LineEnding: zapcore.DefaultLineEnding,
134 EncodeLevel: zapcore.LowercaseLevelEncoder,
135 EncodeTime: zapcore.EpochTimeEncoder,
136 EncodeDuration: zapcore.SecondsDurationEncoder,
137 EncodeCaller: zapcore.ShortCallerEncoder,
138 }
139}
140
141// NewProductionConfig builds a reasonable default production logging
142// configuration.

Callers 5

ExampleAtomicLevelFunction · 0.92
newZapLoggerFunction · 0.92
NewProductionConfigFunction · 0.85

Calls

no outgoing calls

Tested by 4

ExampleAtomicLevelFunction · 0.74
newZapLoggerFunction · 0.74