aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFrancis Lavoie <[email protected]>2024-02-09 00:21:57 -0500
committerFrancis Lavoie <[email protected]>2024-04-15 15:10:05 -0400
commit71959d20f4ad4be91212526898c1d6fc625e0bcd (patch)
tree5afbc6b9f179c7c7831046b2df15734229735a7b
parent4326c737708f72356bc0c376a8353072386ea88a (diff)
downloadcaddy-71959d20f4ad4be91212526898c1d6fc625e0bcd.tar.gz
caddy-71959d20f4ad4be91212526898c1d6fc625e0bcd.zip
Lint
-rw-r--r--modules/caddyhttp/logging.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/modules/caddyhttp/logging.go b/modules/caddyhttp/logging.go
index 0fc85ab90..9930be6bc 100644
--- a/modules/caddyhttp/logging.go
+++ b/modules/caddyhttp/logging.go
@@ -69,8 +69,9 @@ type ServerLogConfig struct {
// wrapLogger wraps logger in one or more logger named
// according to user preferences for the given host.
func (slc ServerLogConfig) wrapLogger(logger *zap.Logger, host string) []*zap.Logger {
- var loggers []*zap.Logger
- for _, loggerName := range slc.getLoggerHosts(host) {
+ hosts := slc.getLoggerHosts(host)
+ loggers := make([]*zap.Logger, 0, len(hosts))
+ for _, loggerName := range hosts {
if loggerName == "" {
continue
}
@@ -89,7 +90,7 @@ func (slc ServerLogConfig) getLoggerHosts(host string) []string {
// match "example.com" if there is no "example.com:1234" in the map)
hostOnly, _, err := net.SplitHostPort(key)
if err != nil {
- return []string{""}, false
+ return []string{}, false
}
if hosts, ok := slc.LoggerMapping[hostOnly]; ok {
return hosts, ok
@@ -105,7 +106,7 @@ func (slc ServerLogConfig) getLoggerHosts(host string) []string {
// match "example.com" if there is no "example.com:1234" in the map)
hostOnly, _, err = net.SplitHostPort(key)
if err != nil {
- return []string{""}, false
+ return []string{}, false
}
host, ok := slc.LoggerNames[hostOnly]
return []string{host}, ok