rollbar.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package logger
  2. import (
  3. "net/http"
  4. "strings"
  5. )
  6. var RollBarEnabled = false
  7. type RollBarStatusCodes []int
  8. var RollBarSkipStatusCodes = RollBarStatusCodes{
  9. http.StatusContinue, // 100
  10. http.StatusSwitchingProtocols, // 101
  11. http.StatusProcessing, // 102
  12. http.StatusEarlyHints, // 103
  13. http.StatusOK, // 200
  14. http.StatusCreated, // 201
  15. http.StatusAccepted, // 202
  16. http.StatusNonAuthoritativeInfo, // 203
  17. http.StatusNoContent, // 204
  18. http.StatusResetContent, // 205
  19. http.StatusPartialContent, // 206
  20. http.StatusMultiStatus, // 207
  21. http.StatusAlreadyReported, // 208
  22. http.StatusIMUsed, // 226
  23. http.StatusMultipleChoices, // 300
  24. http.StatusMovedPermanently, // 301
  25. http.StatusFound, // 302
  26. http.StatusSeeOther, // 303
  27. http.StatusNotModified, // 304
  28. http.StatusUseProxy, // 305
  29. http.StatusTemporaryRedirect, // 307
  30. http.StatusPermanentRedirect, // 308
  31. http.StatusForbidden, // 403
  32. http.StatusNotFound, // 404
  33. http.StatusMethodNotAllowed, // 405
  34. }
  35. func (r RollBarStatusCodes) contain(status int) bool {
  36. for _, v := range r {
  37. if v == status {
  38. return true
  39. }
  40. }
  41. return false
  42. }
  43. type RollBarErrors []string
  44. var RollBarSkipErrors = RollBarErrors{}
  45. func (r RollBarErrors) contain(str string) bool {
  46. for _, v := range r {
  47. if v == str || strings.Contains(str, v) {
  48. return true
  49. }
  50. }
  51. return false
  52. }