()
| 325 | } |
| 326 | |
| 327 | func ChangeColorEncoding() (*zap.Logger, error) { |
| 328 | // For non-color mode, use the standard console encoder. |
| 329 | LogCfg.Encoding = "console" |
| 330 | LogCfg.EncoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder |
| 331 | |
| 332 | // Build the core ourselves rather than using LogCfg.Build so the |
| 333 | // underlying WriteSyncer passes through wrapWriter. zap.Config.Build |
| 334 | // creates a stock ioCore whose sink we can't reach afterwards, which |
| 335 | // would mean the post-encode RedactEncoded pass never runs in |
| 336 | // --disable-ansi mode and non-string zap fields (Any/Binary/Reflect) |
| 337 | // would leak from that path. |
| 338 | encoder := zapcore.NewConsoleEncoder(LogCfg.EncoderConfig) |
| 339 | core := zapcore.NewCore( |
| 340 | encoder, |
| 341 | wrapWriter(zapcore.AddSync(os.Stdout)), |
| 342 | LogCfg.Level, |
| 343 | ) |
| 344 | return reattachDebugFileSink(zap.New(newRedactingCore(core))), nil |
| 345 | } |
| 346 | |
| 347 | // cappedWriteSyncer wraps a WriteSyncer and stops accepting bytes once |
| 348 | // the running total of accepted bytes reaches cap. Past the cap, Write |
no test coverage detected