mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-16 21:56:40 -05:00
caddyhttp: Match hostnames with wildcards to loggers (#3378)
* adding wildcard matching of logger names * reordering precedence for more specific loggers to match first * removing dependence on certmagic and extra loop Co-authored-by: GregoryDosh <GregoryDosh@users.noreply.github.com>
This commit is contained in:
parent
5bde8d705b
commit
d534162556
1 changed files with 14 additions and 0 deletions
|
@ -456,6 +456,20 @@ func (slc ServerLogConfig) getLoggerName(host string) string {
|
|||
if loggerName, ok := slc.LoggerNames[host]; ok {
|
||||
return loggerName
|
||||
}
|
||||
|
||||
// Try matching wildcard domains if other non-specific loggers exist
|
||||
labels := strings.Split(host, ".")
|
||||
for i := range labels {
|
||||
if labels[i] == "" {
|
||||
continue
|
||||
}
|
||||
labels[i] = "*"
|
||||
wildcardHost := strings.Join(labels, ".")
|
||||
if loggerName, ok := slc.LoggerNames[wildcardHost]; ok {
|
||||
return loggerName
|
||||
}
|
||||
}
|
||||
|
||||
return slc.DefaultLoggerName
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue