File tree Expand file tree Collapse file tree 3 files changed +43
-3
lines changed Expand file tree Collapse file tree 3 files changed +43
-3
lines changed Original file line number Diff line number Diff line change @@ -10,8 +10,10 @@ syslog:
1010 perms : 0666
1111
1212 # Message filtering
13+ # these messages will NOT be shown
1314 filter :
1415 facility : " auth,authpriv"
16+ severity : " debug,info"
1517
1618 # Output manipulation
1719 output :
Original file line number Diff line number Diff line change @@ -71,15 +71,29 @@ func parseConfiguration() {
7171
7272 // set internal defaults
7373 configuration .Syslog .Filter .facility = 9223372036854775807
74+ configuration .Syslog .Filter .severity = 9223372036854775807
7475
7576 // init syslog configuration
7677 if configuration .Syslog .Path != "" {
78+
7779 // Facility filter
78- for _ , facility := range strings .Split (configuration .Syslog .Filter .Facility , "," ) {
79- if facilityId , ok := SyslogFacilityMap [facility ]; ok {
80- configuration .Syslog .Filter .facility = clearBit (configuration .Syslog .Filter .facility , uint (facilityId ))
80+ if configuration .Syslog .Filter .Facility != "" {
81+ for _ , facility := range strings .Split (configuration .Syslog .Filter .Facility , "," ) {
82+ if facilityId , ok := SyslogFacilityMap [facility ]; ok {
83+ configuration .Syslog .Filter .facility = clearBit (configuration .Syslog .Filter .facility , uint (facilityId ))
84+ }
8185 }
8286 }
87+
88+ // Severity filter
89+ if configuration .Syslog .Filter .Severity != "" {
90+ for _ , severity := range strings .Split (configuration .Syslog .Filter .Severity , "," ) {
91+ if severityId , ok := SyslogPriorityMap [severity ]; ok {
92+ configuration .Syslog .Filter .severity = clearBit (configuration .Syslog .Filter .severity , uint (severityId ))
93+ }
94+ }
95+ }
96+
8397 }
8498}
8599
Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ type Syslog struct {
1212 Filter struct {
1313 Facility string
1414 facility int
15+
16+ Severity string
17+ severity int
1518 }
1619 Output struct {
1720 Template string
@@ -46,6 +49,21 @@ var SyslogFacilityMap = map[string]int {
4649 "local7" : 23 ,
4750}
4851
52+ var SyslogPriorityMap = map [string ]int {
53+ "emerg" : 0 ,
54+ "emergency" : 0 ,
55+ "alert" : 1 ,
56+ "crit" : 2 ,
57+ "critical" : 2 ,
58+ "err" : 3 ,
59+ "error" : 3 ,
60+ "warn" : 4 ,
61+ "warning" : 4 ,
62+ "notice" : 5 ,
63+ "info" : 6 ,
64+ "dbg" : 7 ,
65+ "debug" : 7 ,
66+ }
4967
5068func handleSyslog () {
5169 LoggerStdout .Verbose (fmt .Sprintf (" -> starting syslog daemon (%s)" , configuration .Syslog .Path ))
@@ -68,12 +86,18 @@ func handleSyslog() {
6886 go func (channel syslog.LogPartsChannel ) {
6987 for logParts := range channel {
7088 facilityId := uint (logParts ["facility" ].(int ))
89+ severityId := uint (logParts ["severity" ].(int ))
7190
7291 // facility filter
7392 if hasBit (configuration .Syslog .Filter .facility , facilityId ) == false {
7493 continue
7594 }
7695
96+ // severity filter
97+ if hasBit (configuration .Syslog .Filter .severity , severityId ) == false {
98+ continue
99+ }
100+
77101 //fmt.Println(logParts)
78102
79103 // build message
You can’t perform that action at this time.
0 commit comments