You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.0 KiB

  1. # Airbrake Golang Notifier [![Build Status](https://circleci.com/gh/airbrake/gobrake.png?circle-token=4cbcbf1a58fa8275217247351a2db7250c1ef976)](https://circleci.com/gh/airbrake/gobrake)
  2. <img src="http://f.cl.ly/items/3J3h1L05222X3o1w2l2L/golang.jpg" width=800px>
  3. # Example
  4. ```go
  5. package main
  6. import (
  7. "errors"
  8. "gopkg.in/airbrake/gobrake.v2"
  9. )
  10. var airbrake = gobrake.NewNotifier(1234567, "FIXME")
  11. func init() {
  12. airbrake.AddFilter(func(notice *gobrake.Notice) *gobrake.Notice {
  13. notice.Context["environment"] = "production"
  14. return notice
  15. })
  16. }
  17. func main() {
  18. defer airbrake.WaitAndClose(5*time.Second)
  19. defer airbrake.NotifyOnPanic()
  20. airbrake.Notify(errors.New("operation failed"), nil)
  21. }
  22. ```
  23. ## Ignoring notices
  24. ```go
  25. airbrake.AddFilter(func(notice *gobrake.Notice) *gobrake.Notice {
  26. if notice.Context["environment"] == "development" {
  27. // Ignore notices in development environment.
  28. return nil
  29. }
  30. return notice
  31. })
  32. ```
  33. ## Logging
  34. You can use [glog fork](https://github.com/airbrake/glog) to send your logs to Airbrake.