Skip to content
forked from tokopedia/panics

Simple package to catch & notify your panic or exceptions via slack or save into files.

Notifications You must be signed in to change notification settings

nyelonong/panics

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 

Repository files navigation

Panics GoDoc CircleCI GoReportCard

Simple package to catch & notify your panic or exceptions via slack or save into files.

import "github.com/tokopedia/panics"

Configuration

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"},
})

Capture Custom Error

panics.Capture(
    "Deposit Anomaly",
    `{"user_id":123, "deposit_amount" : -100000000}`,
)

Capture Panic on HTTP Handler

http.HandleFunc("/", panics.CaptureHandler(func(w http.ResponseWriter, r *http.Request) {
	panic("Duh aku panik nih guys")
}))

Capture Panic on httprouter handler

router := httprouter.New()
router.POST("/", panics.CaptureHTTPRouterHandler(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
    panic("Duh httprouter aku panik nih guys")
}))

Capture Panic on negroni custom middleware

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
	panic("Duh aku panik nih guys")
})
negro := negroni.New()
negro.Use(negroni.HandlerFunc(CaptureNegroniHandler))

Example

Slack Notification

Notification Example

Authors

About

Simple package to catch & notify your panic or exceptions via slack or save into files.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%