Skip to content

Commit

Permalink
Merge pull request #22 from angristan/fix-example
Browse files Browse the repository at this point in the history
Fix example: logrus.AddHook() args + add deferred flush
  • Loading branch information
onrik authored May 5, 2021
2 parents e90fa26 + 191ffad commit fb0623d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Hooks for [logrus](https://github.com/Sirupsen/logrus)

Example
## Example

```go
package main

Expand All @@ -23,16 +24,16 @@ func main() {

sentryHook, err := sentry.NewHook(sentry.Options{
Dsn: dsn,
})
}, log.PanicLevel, log.FatalLevel, log.ErrorLevel)
if err != nil {
log.Error(err)
return
}
log.AddHook(sentryHook, log.PanicLevel, log.FatalLevel, log.ErrorLevel)
defer sentryHook.Flush()

log.AddHook(sentryHook)

err = fmt.Errorf("test error")
log.WithError(err).Error("Dead beef")
}


```

0 comments on commit fb0623d

Please sign in to comment.