Skip to content

Commit

Permalink
Add logrus safe recoverer
Browse files Browse the repository at this point in the history
  • Loading branch information
dsxack committed Sep 16, 2020
1 parent 7b6b019 commit ca10474
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions safe/logrus/recover.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package logrus

import (
"github.com/dsxack/go/v2/safe"
"github.com/sirupsen/logrus"
"runtime/debug"
)

func init() {
safe.DefaultRecover = RecoverLogger
}

func RecoverLogger(err interface{}) {
logrus.Errorf("Error in Go routine: %s\nStack: %s", err, debug.Stack())
}

0 comments on commit ca10474

Please sign in to comment.