summaryrefslogtreecommitdiff
path: root/caddyconfig/httpcaddyfile
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2022-10-05 14:14:13 -0400
committerGitHub <noreply@github.com>2022-10-05 12:14:13 -0600
commit99ffe9338837eff80def7e5d51c2a0e02f56abdb (patch)
treef9168596a126540e9ab1a38ae79fb7359877e1d5 /caddyconfig/httpcaddyfile
parente07a267276b9c00181c979ec65f26e25b8325beb (diff)
logging: Fix `skip_hosts` with wildcards (#5102)
Fix #4859
Diffstat (limited to 'caddyconfig/httpcaddyfile')
-rw-r--r--caddyconfig/httpcaddyfile/builtins.go2
-rw-r--r--caddyconfig/httpcaddyfile/httptype.go33
2 files changed, 9 insertions, 26 deletions
diff --git a/caddyconfig/httpcaddyfile/builtins.go b/caddyconfig/httpcaddyfile/builtins.go
index 7f23fd5..f4c9ce0 100644
--- a/caddyconfig/httpcaddyfile/builtins.go
+++ b/caddyconfig/httpcaddyfile/builtins.go
@@ -735,7 +735,7 @@ func parseLogHelper(h Helper, globalLogNames map[string]struct{}) ([]ConfigValue
// reference the default logger. See the
// setupNewDefault function in the logging
// package for where this is configured.
- globalLogName = "default"
+ globalLogName = caddy.DefaultLoggerName
}
// Verify this name is unused.
diff --git a/caddyconfig/httpcaddyfile/httptype.go b/caddyconfig/httpcaddyfile/httptype.go
index 7159454..c220c06 100644
--- a/caddyconfig/httpcaddyfile/httptype.go
+++ b/caddyconfig/httpcaddyfile/httptype.go
@@ -219,7 +219,7 @@ func (st ServerType) Setup(inputServerBlocks []caddyfile.ServerBlock,
if ncl.name == "" {
return
}
- if ncl.name == "default" {
+ if ncl.name == caddy.DefaultLoggerName {
hasDefaultLog = true
}
if _, ok := options["debug"]; ok && ncl.log.Level == "" {
@@ -240,7 +240,7 @@ func (st ServerType) Setup(inputServerBlocks []caddyfile.ServerBlock,
// configure it with any applicable options
if _, ok := options["debug"]; ok {
customLogs = append(customLogs, namedCustomLog{
- name: "default",
+ name: caddy.DefaultLoggerName,
log: &caddy.CustomLog{Level: zap.DebugLevel.CapitalString()},
})
}
@@ -299,11 +299,11 @@ func (st ServerType) Setup(inputServerBlocks []caddyfile.ServerBlock,
// most users seem to prefer not writing access logs
// to the default log when they are directed to a
// file or have any other special customization
- if ncl.name != "default" && len(ncl.log.Include) > 0 {
- defaultLog, ok := cfg.Logging.Logs["default"]
+ if ncl.name != caddy.DefaultLoggerName && len(ncl.log.Include) > 0 {
+ defaultLog, ok := cfg.Logging.Logs[caddy.DefaultLoggerName]
if !ok {
defaultLog = new(caddy.CustomLog)
- cfg.Logging.Logs["default"] = defaultLog
+ cfg.Logging.Logs[caddy.DefaultLoggerName] = defaultLog
}
defaultLog.Exclude = append(defaultLog.Exclude, ncl.log.Include...)
}
@@ -518,15 +518,6 @@ func (st *ServerType) serversFromPairings(
var hasCatchAllTLSConnPolicy, addressQualifiesForTLS bool
autoHTTPSWillAddConnPolicy := autoHTTPS != "off"
- // if a catch-all server block (one which accepts all hostnames) exists in this pairing,
- // we need to know that so that we can configure logs properly (see #3878)
- var catchAllSblockExists bool
- for _, sblock := range p.serverBlocks {
- if len(sblock.hostsFromKeys(false)) == 0 {
- catchAllSblockExists = true
- }
- }
-
// if needed, the ServerLogConfig is initialized beforehand so
// that all server blocks can populate it with data, even when not
// coming with a log directive
@@ -658,18 +649,10 @@ func (st *ServerType) serversFromPairings(
} else {
// map each host to the user's desired logger name
for _, h := range sblockLogHosts {
- // if the custom logger name is non-empty, add it to the map;
- // otherwise, only map to an empty logger name if this or
- // another site block on this server has a catch-all host (in
- // which case only requests with mapped hostnames will be
- // access-logged, so it'll be necessary to add them to the
- // map even if they use default logger)
- if ncl.name != "" || catchAllSblockExists {
- if srv.Logs.LoggerNames == nil {
- srv.Logs.LoggerNames = make(map[string]string)
- }
- srv.Logs.LoggerNames[h] = ncl.name
+ if srv.Logs.LoggerNames == nil {
+ srv.Logs.LoggerNames = make(map[string]string)
}
+ srv.Logs.LoggerNames[h] = ncl.name
}
}
}