add input/ouput fields for log

This commit is contained in:
ginuerzh
2024-10-16 22:16:34 +08:00
parent 24547b4332
commit 618d042001
13 changed files with 72 additions and 16 deletions
+4 -1
View File
@@ -102,6 +102,7 @@ func (h *ssHandler) Handle(ctx context.Context, conn net.Conn, opts ...handler.H
"remote": conn.RemoteAddr().String(),
"local": conn.LocalAddr().String(),
"sid": ctxvalue.SidFromContext(ctx),
"client": ro.ClientIP,
})
log.Infof("%s <> %s", conn.RemoteAddr(), conn.LocalAddr())
@@ -120,7 +121,9 @@ func (h *ssHandler) Handle(ctx context.Context, conn net.Conn, opts ...handler.H
}
log.WithFields(map[string]any{
"duration": time.Since(start),
"duration": time.Since(start),
"inputBytes": ro.InputBytes,
"outputBytes": ro.OutputBytes,
}).Infof("%s >< %s", conn.RemoteAddr(), conn.LocalAddr())
}()