Awesome Open Source
Awesome Open Source
Sponsorship

Hooks for logrus

Example

package main

import (
  "net/http"
  
  "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)
  
  log.AddHook(sentry.NewHook(sentry.Options{
    Dsn: dsn,
  }, log.PanicLevel, log.FatalLevel, log.ErrorLevel))
  
  log.WithError(err).Error("Dead beef")
}


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
go (13,642
golang (3,425
logging (362
gin (75
sentry (53
gorm (44
echo (34
gin-gonic (17

Find Open Source By Browsing 7,000 Topics Across 59 Categories