Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

README

        

# Hooks for [logrus](https://github.com/Sirupsen/logrus)

## Example

```go
package main

import (
"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")
}
```