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

Method Logger

logging.go:219–246  ·  logging.go::Logging.Logger

Logger returns a logger that is ready for the module to use.

(mod Module)

Source from the content-addressed store, hash-verified

217
218// Logger returns a logger that is ready for the module to use.
219func (logging *Logging) Logger(mod Module) *zap.Logger {
220 modID := string(mod.CaddyModule().ID)
221 var cores []zapcore.Core
222 var options []zap.Option
223
224 if logging != nil {
225 for _, l := range logging.Logs {
226 if l.matchesModule(modID) {
227 if len(l.Include) == 0 && len(l.Exclude) == 0 {
228 cores = append(cores, l.core)
229 continue
230 }
231 if len(options) == 0 {
232 newOptions, err := l.buildOptions()
233 if err != nil {
234 Log().Error("building options for logger", zap.String("module", modID), zap.Error(err))
235 }
236 options = newOptions
237 }
238 cores = append(cores, &filteringCore{Core: l.core, cl: l})
239 }
240 }
241 }
242
243 multiCore := zapcore.NewTee(cores...)
244
245 return zap.New(multiCore, options...).Named(modID)
246}
247
248// openWriter opens a writer using opener, and returns true if
249// the writer is new, or false if the writer already exists.

Callers 15

ProvisionMethod · 0.45
ProvisionMethod · 0.45
ProvisionMethod · 0.45
ProvisionMethod · 0.45
ProvisionMethod · 0.45
ProvisionMethod · 0.45
ProvisionMethod · 0.45
ProvisionMethod · 0.45
ProvisionMethod · 0.45
ProvisionMethod · 0.45
loadECHConfigFunction · 0.45
ProvisionMethod · 0.45

Calls 6

LogFunction · 0.85
matchesModuleMethod · 0.80
buildOptionsMethod · 0.80
CaddyModuleMethod · 0.65
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected