logrus/hooks/syslog
dmathieu f30ff25fb7 rename logrus_syslog package to syslog
Package names shouldn't be using underscores. There is also nothing
wrong with naming this package `syslog`. People can include it with any
name they wish.
2017-07-18 15:18:46 +02:00
..
README.md rename logrus_syslog package to syslog 2017-07-18 15:18:46 +02:00
syslog.go rename logrus_syslog package to syslog 2017-07-18 15:18:46 +02:00
syslog_test.go rename logrus_syslog package to syslog 2017-07-18 15:18:46 +02:00

README.md

Syslog Hooks for Logrus :walrus:

Usage

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

func main() {
  log       := logrus.New()
  hook, err := lSyslog.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"
  lSyslog "github.com/sirupsen/logrus/hooks/syslog"
)

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

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