Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Commit

Permalink
Only log JSON to file
Browse files Browse the repository at this point in the history
  • Loading branch information
meeDamian committed Jan 3, 2020
1 parent cfbb64c commit b4acd4e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,21 @@ func init() {
"log-file": conf.LogFile,
}

// After all initialization has been done, start logging to log file
if conf.LogFile != "none" {
// Write current config to stdout
log.WithFields(fields).Println("invoicer started")

// After all initialization has been done, start logging to log file
log.SetOutput(&lumberjack.Logger{
Filename: common.CleanAndExpandPath(conf.LogFile),
LocalTime: true,
Compress: true,
})

log.SetFormatter(&log.JSONFormatter{
PrettyPrint: false, // Having `false` here makes sure that `jq` always works on `tail -f`.
})
}
log.SetFormatter(&log.JSONFormatter{
PrettyPrint: false, // Having `false` here makes sure that `jq` always works on `tail -f`.
})

// Write current config to log file
log.WithFields(fields).Println("invoicer started")
Expand Down

0 comments on commit b4acd4e

Please sign in to comment.