Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions common/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}

Expand Down