core: Return default logger if no modules loaded

Fix report from:
https://caddy.community/t/remote-caddyfile-invalid-memory-address-or-nil-pointer-dereference/19700/3
This commit is contained in:
Matthew Holt 2023-04-20 10:27:40 -06:00
parent b301a3df70
commit c6ac350a3b
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5

View file

@ -480,6 +480,9 @@ func (ctx Context) Logger(module ...Module) *zap.Logger {
if len(module) > 0 { if len(module) > 0 {
mod = module[0] mod = module[0]
} }
if mod == nil {
return Log()
}
return ctx.cfg.Logging.Logger(mod) return ctx.cfg.Logging.Logger(mod)
} }