diff --git a/main.go b/main.go index 71053a8..77f73dc 100644 --- a/main.go +++ b/main.go @@ -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))