Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
Enable log to journal only when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Biesmans committed Oct 11, 2017
1 parent 0a6ad83 commit 0160ca3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ import (

"runtime/debug"

"github.com/coreos/go-systemd/journal"
"github.com/remyLemeunier/contactkey/commands"
log "github.com/sirupsen/logrus"
"github.com/wercker/journalhook"
)

func main() {
log.AddHook(&journalhook.JournalHook{})
if journal.Enabled() {
log.AddHook(&journalhook.JournalHook{})
}

defer func() {
if r := recover(); r != nil {
log.WithFields(log.Fields{"stacktrace": string(debug.Stack())}).Error(fmt.Sprintf("Recovered from panic %q", r))
Expand Down

0 comments on commit 0160ca3

Please sign in to comment.