Skip to content

Commit

Permalink
Add ability to output logs in JSON format
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Roemmich <[email protected]>
  • Loading branch information
croemmich committed May 13, 2019
1 parent f65dacf commit 476e43c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ func setupLogrus() {
}
logrus.SetLevel(l)
logrus.SetOutput(os.Stdout)
switch Config.LogrusFormat {
case "text":
logrus.SetFormatter(&logrus.TextFormatter{})
case "json":
logrus.SetFormatter(&logrus.JSONFormatter{})
default:
logrus.Warnf("unexpected logrus format: %s, should be one of: text, json", Config.LogrusFormat)
}
}

func setupSentry() {
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ var Config = struct {

// LogrusLevel sets the logrus logging level
LogrusLevel string `env:"FLAGR_LOGRUS_LEVEL" envDefault:"info"`
// LogrusFormat sets the logrus logging formatter
// Possible values: text, json
LogrusFormat string `env:"FLAGR_LOGRUS_FORMAT" envDefault:"text"`
// PProfEnabled - to enable the standard pprof of golang's http server
PProfEnabled bool `env:"FLAGR_PPROF_ENABLED" envDefault:"true"`

Expand Down

0 comments on commit 476e43c

Please sign in to comment.