Skip to content
/ panics Public

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

alileza/panics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 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.

Topics

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages