MCPcopy
hub / github.com/caddyserver/caddy / newDefaultProductionLogEncoder

Function newDefaultProductionLogEncoder

logging.go:735–749  ·  view source on GitHub ↗
(wo WriterOpener)

Source from the content-addressed store, hash-verified

733}
734
735func newDefaultProductionLogEncoder(wo WriterOpener) zapcore.Encoder {
736 encCfg := zap.NewProductionEncoderConfig()
737 if IsWriterStandardStream(wo) && term.IsTerminal(int(os.Stderr.Fd())) {
738 // if interactive terminal, make output more human-readable by default
739 encCfg.EncodeTime = func(ts time.Time, encoder zapcore.PrimitiveArrayEncoder) {
740 encoder.AppendString(ts.UTC().Format("2006/01/02 15:04:05.000"))
741 }
742 if coloringEnabled {
743 encCfg.EncodeLevel = zapcore.CapitalColorLevelEncoder
744 }
745
746 return zapcore.NewConsoleEncoder(encCfg)
747 }
748 return zapcore.NewJSONEncoder(encCfg)
749}
750
751func parseLevel(levelInput string) (zapcore.LevelEnabler, error) {
752 repl := NewReplacer()

Callers 2

provisionCommonMethod · 0.85
newDefaultProductionLogFunction · 0.85

Calls 1

IsWriterStandardStreamFunction · 0.85

Tested by

no test coverage detected