Skip to content

Commit 659fc91

Browse files
committed
feat(logging): log timestamps in RFC3339Milli
- Changes the timestamp format to human-readable RFC3339. - Increases the precision to millisecond from second.
1 parent b261d60 commit 659fc91

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

common/logging.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@ import (
66
"github.com/sirupsen/logrus"
77
)
88

9+
// RFC3339Milli is a RFC3339 timestamp format restricted to millisecond precision.
10+
// No standard format is provided, so we create our own.
11+
const RFC3339Milli = "2006-01-02T15:04:05.000Z07:00"
12+
913
func LogSetup(json bool, logLevel string) *logrus.Entry {
1014
log := logrus.NewEntry(logrus.New())
1115
log.Logger.SetOutput(os.Stdout)
1216

1317
if json {
14-
log.Logger.SetFormatter(&logrus.JSONFormatter{})
18+
log.Logger.SetFormatter(&logrus.JSONFormatter{
19+
TimestampFormat: RFC3339Milli,
20+
})
1521
} else {
1622
log.Logger.SetFormatter(&logrus.TextFormatter{
17-
FullTimestamp: true,
23+
TimestampFormat: RFC3339Milli,
24+
FullTimestamp: true,
1825
})
1926
}
2027

0 commit comments

Comments
 (0)