@marcel91200 / caddy Mirror · read-only / commits / af732151
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 13, 18:00 UTC

httpcaddyfile: Fix duplicate access log when debug is on (#4746)

Francis Lavoie committed Apr 28, 2022 at 12:16 UTC af7321511c960120d61cfd22e031f43071d5a9c2
2 files changed +55 -8
caddyconfig/httpcaddyfile/httptype.go
+10 -8
@@ -254,20 +254,13 @@ func (st ServerType) Setup(inputServerBlocks []caddyfile.ServerBlock,
254 }
255 customLogs = append(customLogs, ncl)
256 }
257 +
258 // Apply global log options, when set
259 if options["log"] != nil {
260 for _, logValue := range options["log"].([]ConfigValue) {
261 addCustomLog(logValue.Value.(namedCustomLog))
262 }
263 }
263 - // Apply server-specific log options
264 - for _, p := range pairings {
265 - for _, sb := range p.serverBlocks {
266 - for _, clVal := range sb.pile["custom_log"] {
267 - addCustomLog(clVal.Value.(namedCustomLog))
268 - }
269 - }
270 - }
264
265 if !hasDefaultLog {
266 // if the default log was not customized, ensure we
@@ -280,6 +273,15 @@ func (st ServerType) Setup(inputServerBlocks []caddyfile.ServerBlock,
273 }
274 }
275
276 + // Apply server-specific log options
277 + for _, p := range pairings {
278 + for _, sb := range p.serverBlocks {
279 + for _, clVal := range sb.pile["custom_log"] {
280 + addCustomLog(clVal.Value.(namedCustomLog))
281 + }
282 + }
283 + }
284 +
285 // annnd the top-level config, then we're done!
286 cfg := &caddy.Config{AppsRaw: make(caddy.ModuleMap)}
287
caddytest/integration/caddyfile_adapt/global_options_debug_with_access_log.txt new
+45
@@ -0,0 +1,45 @@
1 +{
2 + debug
3 +}
4 +
5 +:8881 {
6 + log {
7 + format console
8 + }
9 +}
10 +----------
11 +{
12 + "logging": {
13 + "logs": {
14 + "default": {
15 + "level": "DEBUG",
16 + "exclude": [
17 + "http.log.access.log0"
18 + ]
19 + },
20 + "log0": {
21 + "encoder": {
22 + "format": "console"
23 + },
24 + "level": "DEBUG",
25 + "include": [
26 + "http.log.access.log0"
27 + ]
28 + }
29 + }
30 + },
31 + "apps": {
32 + "http": {
33 + "servers": {
34 + "srv0": {
35 + "listen": [
36 + ":8881"
37 + ],
38 + "logs": {
39 + "default_logger_name": "log0"
40 + }
41 + }
42 + }
43 + }
44 + }
45 +}
\ No newline at end of file