Selaa lähdekoodia

Add Bugsnag logger

DarthSim 1 vuosi sitten
vanhempi
commit
a31e4e7c79
1 muutettua tiedostoa jossa 8 lisäystä ja 0 poistoa
  1. 8 0
      errorreport/bugsnag/bugsnag.go

+ 8 - 0
errorreport/bugsnag/bugsnag.go

@@ -4,18 +4,26 @@ import (
 	"net/http"
 
 	"github.com/bugsnag/bugsnag-go/v2"
+	"github.com/sirupsen/logrus"
 
 	"github.com/imgproxy/imgproxy/v3/config"
 )
 
 var enabled bool
 
+type logger struct{}
+
+func (l logger) Printf(format string, v ...interface{}) {
+	logrus.WithField("source", "bugsnag").Debugf(format, v...)
+}
+
 func Init() {
 	if len(config.BugsnagKey) > 0 {
 		bugsnag.Configure(bugsnag.Configuration{
 			APIKey:       config.BugsnagKey,
 			ReleaseStage: config.BugsnagStage,
 			PanicHandler: func() {}, // Disable forking the process
+			Logger:       logger{},
 		})
 		enabled = true
 	}