changes
This commit is contained in:
@@ -13,14 +13,16 @@ func InitSyslog() {
|
||||
if config.Config.Syslog.Enable == "true" {
|
||||
// Parse facility
|
||||
facility := parseFacility(config.Config.Syslog.Facility)
|
||||
|
||||
|
||||
// Parse severity
|
||||
severity := parseSeverity(config.Config.Syslog.Severity)
|
||||
|
||||
|
||||
// Combine to priority
|
||||
priority := facility | severity
|
||||
|
||||
|
||||
var err error
|
||||
|
||||
// Connect to remote syslog server
|
||||
syslogWriter, err = syslog.Dial(
|
||||
config.Config.Syslog.Network,
|
||||
config.Config.Syslog.Server,
|
||||
@@ -41,7 +43,7 @@ func WriteSyslog(message Message) {
|
||||
log.Printf("Failed to marshal message to JSON: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// Send to syslog based on configured severity
|
||||
switch config.Config.Syslog.Severity {
|
||||
case "emerg":
|
||||
@@ -89,7 +91,7 @@ func parseFacility(facility string) syslog.Priority {
|
||||
"local6": syslog.LOG_LOCAL6,
|
||||
"local7": syslog.LOG_LOCAL7,
|
||||
}
|
||||
|
||||
|
||||
if f, ok := facilities[facility]; ok {
|
||||
return f
|
||||
}
|
||||
@@ -107,7 +109,7 @@ func parseSeverity(severity string) syslog.Priority {
|
||||
"info": syslog.LOG_INFO,
|
||||
"debug": syslog.LOG_DEBUG,
|
||||
}
|
||||
|
||||
|
||||
if s, ok := severities[severity]; ok {
|
||||
return s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user