bugsnag.go 420 B

1234567891011121314151617181920212223242526
  1. package bugsnag
  2. import (
  3. "net/http"
  4. "github.com/bugsnag/bugsnag-go/v2"
  5. "github.com/imgproxy/imgproxy/v3/config"
  6. )
  7. var enabled bool
  8. func Init() {
  9. if len(config.BugsnagKey) > 0 {
  10. bugsnag.Configure(bugsnag.Configuration{
  11. APIKey: config.BugsnagKey,
  12. ReleaseStage: config.BugsnagStage,
  13. })
  14. enabled = true
  15. }
  16. }
  17. func Report(err error, req *http.Request) {
  18. if enabled {
  19. bugsnag.Notify(err, req)
  20. }
  21. }