Skip to content

Commit 6bcb1e1

Browse files
authored
log latency with fixed time unit (#2)
* add logger name to every log request * log latency as microseconds int
1 parent 2a6a90c commit 6bcb1e1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

logr.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func Ginlogr(logger logr.Logger, timeFormat string, utc, addToReqContext bool, w
4545
c.Next()
4646

4747
end := time.Now()
48-
latency := end.Sub(start)
48+
latency := end.Sub(start).Microseconds()
4949
if utc {
5050
end = end.UTC()
5151
}
@@ -65,6 +65,7 @@ func Ginlogr(logger logr.Logger, timeFormat string, utc, addToReqContext bool, w
6565
"user-agent", c.Request.UserAgent(),
6666
"time", end.Format(timeFormat),
6767
"latency", latency,
68+
"logger", "ginlogr",
6869
)
6970
}
7071
}

0 commit comments

Comments
 (0)