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

Function newDefaultProductionLog

logging.go:710–733  ·  view source on GitHub ↗

newDefaultProductionLog configures a custom log that is intended for use by default if no other log is specified in a config. It writes to stderr, uses the console encoder, and enables INFO-level logs and higher.

()

Source from the content-addressed store, hash-verified

708// in a config. It writes to stderr, uses the console encoder,
709// and enables INFO-level logs and higher.
710func newDefaultProductionLog() (*defaultCustomLog, error) {
711 cl := new(CustomLog)
712 cl.writerOpener = StderrWriter{}
713 var err error
714 cl.writer, err = cl.writerOpener.OpenWriter()
715 if err != nil {
716 return nil, err
717 }
718 cl.encoder = newDefaultProductionLogEncoder(cl.writerOpener)
719 cl.levelEnabler = zapcore.InfoLevel
720
721 cl.buildCore()
722
723 logger := zap.New(cl.core)
724
725 // capture logs from other libraries which
726 // may not be using zap logging directly
727 _ = zap.RedirectStdLog(logger)
728
729 return &defaultCustomLog{
730 CustomLog: cl,
731 logger: logger,
732 }, nil
733}
734
735func newDefaultProductionLogEncoder(wo WriterOpener) zapcore.Encoder {
736 encCfg := zap.NewProductionEncoderConfig()

Callers 2

setupNewDefaultMethod · 0.85
logging.goFile · 0.85

Calls 3

buildCoreMethod · 0.80
OpenWriterMethod · 0.65

Tested by

no test coverage detected