Skip to content

Commit

Permalink
Merge pull request #127 from atomist-skills/allow-json-logging
Browse files Browse the repository at this point in the history
allow setting log format to json
  • Loading branch information
chrispatrick authored Aug 15, 2024
2 parents b1f233f + eeb05eb commit 4df34a1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,16 @@ func init() {
Log.SetLevel(logrus.WarnLevel)
}
}
Log.SetFormatter(&logrus.TextFormatter{
DisableTimestamp: true,
PadLevelText: true,
ForceColors: runtime.GOOS != "windows",
})

if v, ok := os.LookupEnv("ATOMIST_LOG_FORMAT"); ok && v == "json" {
Log.SetFormatter(&logrus.JSONFormatter{})
} else {
Log.SetFormatter(&logrus.TextFormatter{
DisableTimestamp: true,
PadLevelText: true,
ForceColors: runtime.GOOS != "windows",
})
}

// try to obtain the GCP project id
if _, ok := os.LookupEnv("K_SERVICE"); ok {
Expand Down

0 comments on commit 4df34a1

Please sign in to comment.