From 2aea4a7a51e1709e759211507f18bb65392cb4c2 Mon Sep 17 00:00:00 2001 From: xvzc <45588457+xvzc@users.noreply.github.com> Date: Thu, 29 Aug 2024 07:50:08 +0900 Subject: [PATCH] fix: get ctx logger on new request (#198) * fix: get ctx logger on new request * chore: change log format * fix: get ctx logger on new request --- proxy/proxy.go | 1 + util/log/log.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index e936051..7bdceb5 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -65,6 +65,7 @@ func (pxy *Proxy) Start(ctx context.Context) { go func() { ctx := util.GetCtxWithTraceId(ctx) + logger := log.GetCtxLogger(ctx) pkt, err := packet.ReadHttpRequest(conn) if err != nil { diff --git a/util/log/log.go b/util/log/log.go index 4d1ee1e..6dab9a6 100644 --- a/util/log/log.go +++ b/util/log/log.go @@ -23,8 +23,8 @@ func GetCtxLogger(ctx context.Context) zerolog.Logger { func InitLogger(cfg *util.Config) { partsOrder := []string{ - zerolog.TimestampFieldName, zerolog.LevelFieldName, + zerolog.TimestampFieldName, traceIdFieldName, scopeFieldName, zerolog.MessageFieldName,