hooks: add airbrake hook

hooks: Add airbrake hook

examples: move around to avoid overloading main

airbarke move around

remove tex.tgo

readme: cleanup

readme: try something different
This commit is contained in:
Simon Eskildsen
2014-04-13 18:17:20 -04:00
parent b73d08314f
commit d4f08ce128
6 changed files with 175 additions and 46 deletions
+24 -3
View File
@@ -107,11 +107,15 @@ seen as a hint you want to add a field, however, you can still use the
#### Hooks
You can add hooks for logging levels. For example to send errors to an exception
tracking service on `Error`, `Fatal` and `Panic` or info to StatsD.
tracking service on `Error`, `Fatal` and `Panic` or info to StatsD. Note this is
not the real implementation of the Airbrake hook in logrus, just a sample.
```go
log = logrus.New()
log.Hooks.Add(new(AirbrakeHook))
var log = logrus.New()
func init() {
log.Hooks.Add(new(AirbrakeHook))
}
type AirbrakeHook struct{}
@@ -139,6 +143,23 @@ func (hook *AirbrakeHook) Levels() []logrus.Level {
}
```
Logrus comes with built-in hooks. Add those, or your custom hook, in `init`:
```go
import (
"github.com/Sirupsen/logrus"
"github.com/Sirupsen/logrus/hooks/airbrake"
)
func init() {
log.Hooks.Add(new(logrus_airbrake.AirbrakeHook))
}
```
* [`github.com/Sirupsen/logrus/hooks/airbrake`](https://github.com/Sirupsen/logrus/blob/master/hooks/airbrake/airbrake.go).
Send errors to an exception tracking service compatible with the Airbrake API.
Uses [`airbrake-go`](https://github.com/tobi/airbrake-go) behind the scenes.
#### Level logging
Logrus has six logging levels: Debug, Info, Warning, Error, Fatal and Panic.