diff --git a/internal/chi/log_formatter.go b/internal/chi/log_formatter.go index c3d604f..cd57c0d 100644 --- a/internal/chi/log_formatter.go +++ b/internal/chi/log_formatter.go @@ -16,6 +16,7 @@ type LogFormatter struct{} func (*LogFormatter) NewLogEntry(r *http.Request) middleware.LogEntry { return &LogEntry{ method: r.Method, + host: r.Host, path: r.URL.Path, ctx: r.Context(), } @@ -29,6 +30,7 @@ var _ middleware.LogFormatter = &LogFormatter{} type LogEntry struct { method string + host string path string ctx context.Context } @@ -41,6 +43,7 @@ func (e *LogEntry) Panic(v interface{}, stack []byte) { // Write implements middleware.LogEntry func (e *LogEntry) Write(status int, bytes int, header http.Header, elapsed time.Duration, extra interface{}) { logger.Info(e.ctx, fmt.Sprintf("%s %s - %d", e.method, e.path, status), + logger.F("host", e.host), logger.F("status", status), logger.F("bytes", bytes), logger.F("elapsed", elapsed),