Merge pull request #816 from sirupsen/syslog_hook_example

Use syslog instead of airbrake as syslog example
This commit is contained in:
David Bariod 2018-09-04 22:21:35 +02:00 committed by GitHub
commit 3791101e14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -1,16 +1,22 @@
// +build !windows
package logrus_test
import (
"github.com/sirupsen/logrus"
"gopkg.in/gemnasium/logrus-airbrake-hook.v2"
slhooks "github.com/sirupsen/logrus/hooks/syslog"
"log/syslog"
"os"
)
// An example on how to use a hook
func Example_hook() {
var log = logrus.New()
log.Formatter = new(logrus.TextFormatter) // default
log.Formatter.(*logrus.TextFormatter).DisableTimestamp = true // remove timestamp from test output
log.Hooks.Add(airbrake.NewHook(123, "xyz", "development"))
if sl, err := slhooks.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, ""); err != nil {
log.Hooks.Add(sl)
}
log.Out = os.Stdout
log.WithFields(logrus.Fields{