Logging: fix robots not showing client into

This commit is contained in:
kayos@tcp.direct 2023-01-03 09:37:12 -08:00
parent 15f1838aa8
commit 4931c51a61
No known key found for this signature in database
GPG Key ID: 4B841471B4BEE979
1 changed files with 6 additions and 2 deletions

View File

@ -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")
}
}