Use slog.DiscardHandler when logging is disabled

This change switches to using slog.DiscardHandler, added to Go 1.24, when logging is disabled.
This commit is contained in:
Ryan Smith
2025-03-03 22:26:41 -08:00
parent 122e1ca83d
commit 3e72919170

View File

@@ -211,7 +211,7 @@ func (c *Config) InitializeLoggers() error {
// If no log path is specified or if logging is disabled, discard logs.
if len(logPath) == 0 || !c.Servers[i].LogEnabled {
c.Servers[i].Logger = slog.New(slog.NewTextHandler(io.Discard, nil))
c.Servers[i].Logger = slog.New(slog.DiscardHandler)
continue
}