Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/onrik/logrus
Hooks for logrus logging
https://github.com/onrik/logrus
echo gin gin-gonic gin-middleware golang gorm gorm-orm logging logrus sentry sentry-client
Last synced: about 1 month ago
JSON representation
Hooks for logrus logging
- Host: GitHub
- URL: https://github.com/onrik/logrus
- Owner: onrik
- License: mit
- Created: 2016-11-26T07:59:30.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2024-07-25T10:28:31.000Z (4 months ago)
- Last Synced: 2024-10-01T01:01:36.117Z (about 1 month ago)
- Topics: echo, gin, gin-gonic, gin-middleware, golang, gorm, gorm-orm, logging, logrus, sentry, sentry-client
- Language: Go
- Homepage:
- Size: 79.1 KB
- Stars: 122
- Watchers: 9
- Forks: 30
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Hooks for [logrus](https://github.com/Sirupsen/logrus)
## Example
```go
package mainimport (
"fmt""github.com/onrik/logrus/filename"
"github.com/onrik/logrus/sentry"
log "github.com/sirupsen/logrus"
)var (
dsn = "http://[email protected]/1"
)func main() {
filenameHook := filename.NewHook()
filenameHook.Field = "custom_source_field" // Customize source field name
log.AddHook(filenameHook)sentryHook, err := sentry.NewHook(sentry.Options{
Dsn: dsn,
}, log.PanicLevel, log.FatalLevel, log.ErrorLevel)
if err != nil {
log.Error(err)
return
}
defer sentryHook.Flush()
log.AddHook(sentryHook)err = fmt.Errorf("test error")
log.WithError(err).Error("Dead beef")
}
```