RedirectToStderr re-creates the logger writing to stderr instead of stdout. Use this when --json mode is active to prevent log lines from contaminating structured JSON on stdout.
()
| 294 | // Use this when --json mode is active to prevent log lines from contaminating |
| 295 | // structured JSON on stdout. |
| 296 | func RedirectToStderr() (*zap.Logger, error) { |
| 297 | encoder := NewANSIConsoleEncoder(LogCfg.EncoderConfig) |
| 298 | core := zapcore.NewCore( |
| 299 | encoder, |
| 300 | wrapWriter(zapcore.AddSync(os.Stderr)), |
| 301 | LogCfg.Level, |
| 302 | ) |
| 303 | |
| 304 | logger := zap.New(newRedactingCore(core)) |
| 305 | return reattachDebugFileSink(logger), nil |
| 306 | } |
| 307 | |
| 308 | func AddMode(mode string) (*zap.Logger, error) { |
| 309 | cfg := LogCfg |
no test coverage detected