Skip to content

Commit

Permalink
feat(logging): log timestamps in RFC3339Nano
Browse files Browse the repository at this point in the history
- Changes the timestamp format to human-readable RFC3339.
- Increases the precision to nanosecond from second.
  • Loading branch information
alextes authored Oct 5, 2023
1 parent c52858a commit 6523b33
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions common/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package common

import (
"os"
"time"

"github.com/sirupsen/logrus"
)
Expand All @@ -11,10 +12,13 @@ func LogSetup(json bool, logLevel string) *logrus.Entry {
log.Logger.SetOutput(os.Stdout)

if json {
log.Logger.SetFormatter(&logrus.JSONFormatter{})
log.Logger.SetFormatter(&logrus.JSONFormatter{
TimestampFormat: time.RFC3339Nano,
})
} else {
log.Logger.SetFormatter(&logrus.TextFormatter{
FullTimestamp: true,
TimestampFormat: time.RFC3339Nano,
FullTimestamp: true,
})
}

Expand Down

0 comments on commit 6523b33

Please sign in to comment.