Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alvarios/watcher
Error handler for production servers.
https://github.com/alvarios/watcher
error-reporting go power-server-go slack
Last synced: about 1 month ago
JSON representation
Error handler for production servers.
- Host: GitHub
- URL: https://github.com/alvarios/watcher
- Owner: Alvarios
- License: mit
- Created: 2020-07-29T20:18:23.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-02T22:47:49.000Z (over 4 years ago)
- Last Synced: 2024-06-21T13:14:56.913Z (7 months ago)
- Topics: error-reporting, go, power-server-go, slack
- Language: Go
- Homepage:
- Size: 35.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Watcher
A simple and efficient package to handle staging and production errors.
```cgo
go get github.com/Alvarios/watcher
```## Prerequisite
You need a [Slack application](https://api.slack.com/apps) that supports [incoming webhooks](https://api.slack.com/messaging/webhooks#:~:text=Incoming%20Webhooks%20are%20a%20simple,make%20the%20messages%20stand%20out.).
## Configuration
Create a SlackConfig in your go code.
```go
package myPackageimport "github.com/Alvarios/watcher"
var Watcher watcher.SlackConfig
func main() {
Watcher := watcher.SlackConfig{
WebHook: "https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX",
Application: "Your application name",
}
}
```## Methods
### Error
Send a basic error message to Slack.
```go
package myPackagefunc MyFunction() {
_, err := Watcher.Error("some error message")
}
```### Fatal
Same as Error method, but kills the running server and doesn't return any status.
```go
package myPackagefunc MyFunction() {
Watcher.Fatal("some fatal message")
}
```### GinAbort
A special message formatter for Gin, that also interrupts the request.
```go
package myPackageimport "github.com/gin-gonic/gin"
func MyMiddleware(c *gin.Context) {
Watcher.GinAbort(c, "some error message")
}
```## Copyright
2020 Kushuh - [MIT license](https://github.com/Alvarios/watcher/blob/master/LICENSE)