libs/log: [JSON format] include timestamp (bp #6174) (#6179)

Closes #6146
This commit is contained in:
mergify[bot]
2021-02-25 11:27:49 +04:00
committed by GitHub
parent 55ae781efa
commit 28ce355656
5 changed files with 17 additions and 6 deletions
+10 -1
View File
@@ -11,5 +11,14 @@ import (
// w.Write. The passed Writer must be safe for concurrent use by multiple
// goroutines if the returned Logger will be used concurrently.
func NewTMJSONLogger(w io.Writer) Logger {
return &tmLogger{kitlog.NewJSONLogger(w)}
logger := kitlog.NewJSONLogger(w)
logger = kitlog.With(logger, "ts", kitlog.DefaultTimestampUTC)
return &tmLogger{logger}
}
// NewTMJSONLoggerNoTS is the same as NewTMJSONLogger, but without the
// timestamp.
func NewTMJSONLoggerNoTS(w io.Writer) Logger {
logger := kitlog.NewJSONLogger(w)
return &tmLogger{logger}
}