Simple package to catch & notify your panic or exceptions via slack or save into files.
import "github.com/tokopedia/panics"
panics.SetOptions(&panics.Options{
Env: "TEST",
SlackWebhookURL: "https://hooks.slack.com/services/blablabla/blablabla/blabla",
Filepath: "/var/log/myapplication", // it'll generate panics.log
Tags: panics.Tags{"host": "127.0.0.1", "datacenter":"aws"},
})
panics.Capture(
"Deposit Anomaly",
`{"user_id":123, "deposit_amount" : -100000000}`,
)
http.HandleFunc("/", panics.CaptureHandler(func(w http.ResponseWriter, r *http.Request) {
panic("Duh aku panik nih guys")
}))
router := httprouter.New()
router.POST("/", panics.CaptureHTTPRouterHandler(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
panic("Duh httprouter aku panik nih guys")
}))
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
panic("Duh aku panik nih guys")
})
negro := negroni.New()
negro.Use(negroni.HandlerFunc(CaptureNegroniHandler))