diff --git a/common/logging.go b/common/logging.go index 117f0a89..183614c7 100644 --- a/common/logging.go +++ b/common/logging.go @@ -6,15 +6,22 @@ import ( "github.com/sirupsen/logrus" ) +// RFC3339Milli is a RFC3339 timestamp format restricted to millisecond precision. +// No standard format is provided, so we create our own. +const RFC3339Milli = "2006-01-02T15:04:05.000Z07:00" + func LogSetup(json bool, logLevel string) *logrus.Entry { log := logrus.NewEntry(logrus.New()) log.Logger.SetOutput(os.Stdout) if json { - log.Logger.SetFormatter(&logrus.JSONFormatter{}) + log.Logger.SetFormatter(&logrus.JSONFormatter{ + TimestampFormat: RFC3339Milli, + }) } else { log.Logger.SetFormatter(&logrus.TextFormatter{ - FullTimestamp: true, + TimestampFormat: RFC3339Milli, + FullTimestamp: true, }) }