summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-08 21:23:22 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-08 21:23:22 +0900
commit2e1e29ffac134b89a50271cac7f57978bd782d93 (patch)
tree60b504c4f745162b8ef370863b3411373944f7ac
parent165aea923661333ea23ba06e9b4e0035a5911db3 (diff)
bgpd: support to specify syslog facility
You can specify like: --syslog-facility local0 Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--bgpd.go48
1 files changed, 47 insertions, 1 deletions
diff --git a/bgpd.go b/bgpd.go
index 0d466adb..64e94363 100644
--- a/bgpd.go
+++ b/bgpd.go
@@ -43,6 +43,7 @@ func main() {
LogLevel string `short:"l" long:"log-level" description:"specifying log level"`
LogPlain bool `short:"p" long:"log-plain" description:"use plain format for logging (json by default)"`
UseSyslog string `short:"s" long:"syslog" description:"use syslogd"`
+ Facility string `long:"syslog-facility" description:"specify syslog facility"`
}
_, err := flags.Parse(&opts)
if err != nil {
@@ -68,7 +69,52 @@ func main() {
network = dst[0]
addr = dst[1]
}
- hook, err := logrus_syslog.NewSyslogHook(network, addr, syslog.LOG_INFO, "bgpd")
+
+ facility := syslog.Priority(0)
+ switch opts.Facility {
+ case "kern":
+ facility = syslog.LOG_KERN
+ case "user":
+ facility = syslog.LOG_USER
+ case "mail":
+ facility = syslog.LOG_MAIL
+ case "daemon":
+ facility = syslog.LOG_DAEMON
+ case "auth":
+ facility = syslog.LOG_AUTH
+ case "syslog":
+ facility = syslog.LOG_SYSLOG
+ case "lpr":
+ facility = syslog.LOG_LPR
+ case "news":
+ facility = syslog.LOG_NEWS
+ case "uucp":
+ facility = syslog.LOG_UUCP
+ case "cron":
+ facility = syslog.LOG_CRON
+ case "authpriv":
+ facility = syslog.LOG_AUTHPRIV
+ case "ftp":
+ facility = syslog.LOG_FTP
+ case "local0":
+ facility = syslog.LOG_LOCAL0
+ case "local1":
+ facility = syslog.LOG_LOCAL1
+ case "local2":
+ facility = syslog.LOG_LOCAL2
+ case "local3":
+ facility = syslog.LOG_LOCAL3
+ case "local4":
+ facility = syslog.LOG_LOCAL4
+ case "local5":
+ facility = syslog.LOG_LOCAL5
+ case "local6":
+ facility = syslog.LOG_LOCAL6
+ case "local7":
+ facility = syslog.LOG_LOCAL7
+ }
+
+ hook, err := logrus_syslog.NewSyslogHook(network, addr, syslog.LOG_INFO|facility, "bgpd")
if err != nil {
log.Error("Unable to connect to syslog daemon, ", opts.UseSyslog)
os.Exit(1)