forked from mirror/logrus
readme: fix hook
This commit is contained in:
parent
333c89518d
commit
1399b22d12
|
@ -38,7 +38,7 @@ the much more discoverable:
|
||||||
```go
|
```go
|
||||||
log = logrus.New()
|
log = logrus.New()
|
||||||
|
|
||||||
log.WithFields(&logrus.Fields{
|
log.WithFields(logrus.Fields{
|
||||||
"event": event,
|
"event": event,
|
||||||
"topic": topic,
|
"topic": topic,
|
||||||
"key": key
|
"key": key
|
||||||
|
@ -64,8 +64,8 @@ type AirbrakeHook struct {}
|
||||||
|
|
||||||
// `Fire()` takes the entry that the hook is fired for. `entry.Data[]` contains
|
// `Fire()` takes the entry that the hook is fired for. `entry.Data[]` contains
|
||||||
// the fields for the entry. See the Fields section of the README.
|
// the fields for the entry. See the Fields section of the README.
|
||||||
func (hook *AirbrakeHook) Fire(entry *Entry) (error) {
|
func (hook *AirbrakeHook) Fire(entry *logrus.Entry) error {
|
||||||
err := airbrake.Notify(errors.New(entry.String()))
|
err := airbrake.Notify(entry.Data["error"].(error))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithFields(logrus.Fields{
|
log.WithFields(logrus.Fields{
|
||||||
"source": "airbrake",
|
"source": "airbrake",
|
||||||
|
@ -81,7 +81,7 @@ func (hook *AirbrakeHook) Levels() []logrus.Level {
|
||||||
return []logrus.Level{
|
return []logrus.Level{
|
||||||
logrus.Error,
|
logrus.Error,
|
||||||
logrus.Fatal,
|
logrus.Fatal,
|
||||||
logrus.Panic
|
logrus.Panic,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue