go-mtree/vendor/github.com/Sirupsen/logrus/hooks/syslog
Vincent Batts 50d22c5135 vendor: updating dependencies
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2017-06-24 14:45:05 -04:00
..
README.md vendor: updating dependencies 2017-06-24 14:45:05 -04:00
syslog.go vendor: updating dependencies 2017-06-24 14:45:05 -04:00
syslog_test.go vendor: updating dependencies 2017-06-24 14:45:05 -04:00

Syslog Hooks for Logrus :walrus:

Usage

import (
  "log/syslog"
  "github.com/sirupsen/logrus"
  logrus_syslog "github.com/sirupsen/logrus/hooks/syslog"
)

func main() {
  log       := logrus.New()
  hook, err := logrus_syslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")

  if err == nil {
    log.Hooks.Add(hook)
  }
}

If you want to connect to local syslog (Ex. "/dev/log" or "/var/run/syslog" or "/var/run/log"). Just assign empty string to the first two parameters of NewSyslogHook. It should look like the following.

import (
  "log/syslog"
  "github.com/sirupsen/logrus"
  logrus_syslog "github.com/sirupsen/logrus/hooks/syslog"
)

func main() {
  log       := logrus.New()
  hook, err := logrus_syslog.NewSyslogHook("", "", syslog.LOG_INFO, "")

  if err == nil {
    log.Hooks.Add(hook)
  }
}