From af7321511c960120d61cfd22e031f43071d5a9c2 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 28 Apr 2022 12:16:25 -0400 Subject: httpcaddyfile: Fix duplicate access log when debug is on (#4746) --- caddyconfig/httpcaddyfile/httptype.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'caddyconfig') diff --git a/caddyconfig/httpcaddyfile/httptype.go b/caddyconfig/httpcaddyfile/httptype.go index 5b0d845..242f0b8 100644 --- a/caddyconfig/httpcaddyfile/httptype.go +++ b/caddyconfig/httpcaddyfile/httptype.go @@ -254,20 +254,13 @@ func (st ServerType) Setup(inputServerBlocks []caddyfile.ServerBlock, } customLogs = append(customLogs, ncl) } + // Apply global log options, when set if options["log"] != nil { for _, logValue := range options["log"].([]ConfigValue) { addCustomLog(logValue.Value.(namedCustomLog)) } } - // Apply server-specific log options - for _, p := range pairings { - for _, sb := range p.serverBlocks { - for _, clVal := range sb.pile["custom_log"] { - addCustomLog(clVal.Value.(namedCustomLog)) - } - } - } if !hasDefaultLog { // if the default log was not customized, ensure we @@ -280,6 +273,15 @@ func (st ServerType) Setup(inputServerBlocks []caddyfile.ServerBlock, } } + // Apply server-specific log options + for _, p := range pairings { + for _, sb := range p.serverBlocks { + for _, clVal := range sb.pile["custom_log"] { + addCustomLog(clVal.Value.(namedCustomLog)) + } + } + } + // annnd the top-level config, then we're done! cfg := &caddy.Config{AppsRaw: make(caddy.ModuleMap)} -- cgit v1.2.3