From 942651dc1666a2e8a15690316d67a802eee4aaf1 Mon Sep 17 00:00:00 2001 From: yusing Date: Wed, 18 Dec 2024 07:39:04 +0800 Subject: [PATCH] add time field to json access log --- internal/net/http/accesslog/formatter.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/net/http/accesslog/formatter.go b/internal/net/http/accesslog/formatter.go index 29dabd5..d3ea269 100644 --- a/internal/net/http/accesslog/formatter.go +++ b/internal/net/http/accesslog/formatter.go @@ -20,6 +20,7 @@ type ( CommonFormatter } JSONLogEntry struct { + Time string `json:"time"` IP string `json:"ip"` Method string `json:"method"` Scheme string `json:"scheme"` @@ -101,6 +102,7 @@ func (f JSONFormatter) Format(line *bytes.Buffer, req *http.Request, res *http.R cookies := f.cfg.Cookies.ProcessCookies(req.Cookies()) entry := JSONLogEntry{ + Time: timeNow(), IP: clientIP(req), Method: req.Method, Scheme: scheme(req),