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

Method buildCore

logging.go:396–423  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

394}
395
396func (cl *BaseLog) buildCore() {
397 // logs which only discard their output don't need
398 // to perform encoding or any other processing steps
399 // at all, so just shortcut to a nop core instead
400 if _, ok := cl.writerOpener.(*DiscardWriter); ok {
401 cl.core = zapcore.NewNopCore()
402 return
403 }
404 c := zapcore.NewCore(
405 cl.encoder,
406 zapcore.AddSync(cl.writer),
407 cl.levelEnabler,
408 )
409 if cl.Sampling != nil {
410 if cl.Sampling.Interval == 0 {
411 cl.Sampling.Interval = 1 * time.Second
412 }
413 if cl.Sampling.First == 0 {
414 cl.Sampling.First = 100
415 }
416 if cl.Sampling.Thereafter == 0 {
417 cl.Sampling.Thereafter = 100
418 }
419 c = zapcore.NewSamplerWithOptions(c, cl.Sampling.Interval,
420 cl.Sampling.First, cl.Sampling.Thereafter)
421 }
422 cl.core = c
423}
424
425func (cl *BaseLog) buildOptions() ([]zap.Option, error) {
426 var options []zap.Option

Callers 2

provisionCommonMethod · 0.95
newDefaultProductionLogFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected