From 4931c51a6103f41fdd48abf6c4845dae3ccf912b Mon Sep 17 00:00:00 2001 From: "kayos@tcp.direct" Date: Tue, 3 Jan 2023 09:37:12 -0800 Subject: [PATCH] Logging: fix robots not showing client into --- internal/http/robots.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/http/robots.go b/internal/http/robots.go index 4cbf638..cbb72d4 100644 --- a/internal/http/robots.go +++ b/internal/http/robots.go @@ -10,6 +10,10 @@ import ( ) func robotsTXT(ctx *fasthttp.RequestCtx) { + slog := log.With(). + Str("USERAGENT", string(ctx.UserAgent())). + Str("REMOTE_ADDR", remoteAddr). + Interface("URL", string(ctx.RequestURI())).Logger() paths := &strings.Builder{} paths.WriteString("User-agent: *\r\n") for _, p := range config.Paths { @@ -19,11 +23,11 @@ func robotsTXT(ctx *fasthttp.RequestCtx) { } paths.WriteString("\r\n") - log.Debug(). + slog.Debug(). Strs("PATHS", config.Paths). Msg("SERVE_ROBOTS") if _, err := fmt.Fprintf(ctx, paths.String()); err != nil { - log.Error().Err(err).Msg("SERVE_ROBOTS_ERROR") + slog.Error().Err(err).Msg("SERVE_ROBOTS_ERROR") } }