newConsoleLogger builds a logger whose only sink is the provided writer, at the provided level. Used as the input to AddDebugFileSink in tests so we can inspect both branches independently.
(w zapcore.WriteSyncer, level zapcore.Level)
| 16 | // at the provided level. Used as the input to AddDebugFileSink in tests |
| 17 | // so we can inspect both branches independently. |
| 18 | func newConsoleLogger(w zapcore.WriteSyncer, level zapcore.Level) *zap.Logger { |
| 19 | cfg := zap.NewDevelopmentConfig() |
| 20 | LogCfg = cfg |
| 21 | LogCfg.EncoderConfig.EncodeTime = customTimeEncoder |
| 22 | LogCfg.EncoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder |
| 23 | LogCfg.EncoderConfig.EncodeDuration = zapcore.StringDurationEncoder |
| 24 | LogCfg.EncoderConfig.EncodeCaller = nil |
| 25 | LogCfg.Level = zap.NewAtomicLevelAt(level) |
| 26 | encoder := zapcore.NewConsoleEncoder(LogCfg.EncoderConfig) |
| 27 | core := zapcore.NewCore(encoder, wrapWriter(w), LogCfg.Level) |
| 28 | return zap.New(newRedactingCore(core)) |
| 29 | } |
| 30 | |
| 31 | type syncBuffer struct { |
| 32 | mu bytes.Buffer |
no test coverage detected