From e7833a710680432d908020bbf3491bec296e1b6b Mon Sep 17 00:00:00 2001 From: WeebDataHoarder Date: Tue, 29 Apr 2025 02:03:40 +0200 Subject: [PATCH] cmd: attach slog to all http servers --- cmd/go-away/main.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/go-away/main.go b/cmd/go-away/main.go index 2420ff0..c0bd6c9 100644 --- a/cmd/go-away/main.go +++ b/cmd/go-away/main.go @@ -288,6 +288,8 @@ func main() { fatal(fmt.Errorf("failed to create server: %w", err)) } + server.ErrorLog = slog.NewLogLogger(slog.With("server", "http").Handler(), slog.LevelError) + go func() { handler, err := loadPolicyState() if err != nil { @@ -325,8 +327,9 @@ func main() { mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol) mux.HandleFunc("/debug/pprof/trace", pprof.Trace) debugServer := http.Server{ - Addr: opt.BindDebug, - Handler: mux, + Addr: opt.BindDebug, + Handler: mux, + ErrorLog: slog.NewLogLogger(slog.With("server", "debug").Handler(), slog.LevelError), } slog.Warn( @@ -344,8 +347,9 @@ func main() { mux := http.NewServeMux() mux.Handle("/metrics", promhttp.Handler()) metricsServer := http.Server{ - Addr: opt.BindMetrics, - Handler: mux, + Addr: opt.BindMetrics, + Handler: mux, + ErrorLog: slog.NewLogLogger(slog.With("server", "metrics").Handler(), slog.LevelError), } slog.Warn(