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

Method getSloggerHandler

modules/caddyhttp/logging.go:260–281  ·  view source on GitHub ↗
(handler *extraFieldsSlogHandler)

Source from the content-addressed store, hash-verified

258}
259
260func (e *ExtraLogFields) getSloggerHandler(handler *extraFieldsSlogHandler) (h slog.Handler) {
261 if existing, ok := e.handlers.Load(handler); ok {
262 return existing.(slog.Handler)
263 }
264
265 if handler.moduleID == "" {
266 h = zapslog.NewHandler(handler.core.With(e.fields))
267 } else {
268 h = zapslog.NewHandler(handler.core.With(e.fields), zapslog.WithName(handler.moduleID))
269 }
270
271 if handler.group != "" {
272 h = h.WithGroup(handler.group)
273 }
274 if handler.attrs != nil {
275 h = h.WithAttrs(handler.attrs)
276 }
277
278 e.handlers.Store(handler, h)
279
280 return h
281}
282
283const (
284 // Variable name used to indicate that this request

Callers 1

HandleMethod · 0.80

Calls 4

LoadMethod · 0.80
WithGroupMethod · 0.80
WithAttrsMethod · 0.80
WithMethod · 0.45

Tested by

no test coverage detected