Skip to content

Commit

Permalink
add tag support on syslog logger
Browse files Browse the repository at this point in the history
  • Loading branch information
dmachard committed Oct 12, 2023
1 parent 2c3a6b1 commit ff45517
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions dnsutils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ type Config struct {
TlsMinVersion string `yaml:"tls-min-version"`
Format string `yaml:"format"`
ChannelBufferSize int `yaml:"chan-buffer-size"`
Tag string `yaml:"tag"`
} `yaml:"syslog"`
Fluentd struct {
Enable bool `yaml:"enable"`
Expand Down Expand Up @@ -662,6 +663,7 @@ func (c *Config) SetDefault() {
c.Loggers.Syslog.TlsInsecure = false
c.Loggers.Syslog.TlsMinVersion = TLS_v12
c.Loggers.Syslog.ChannelBufferSize = 65535
c.Loggers.Syslog.Tag = ""

c.Loggers.Fluentd.Enable = false
c.Loggers.Fluentd.RemoteAddress = LOCALHOST_IP
Expand Down
4 changes: 3 additions & 1 deletion docs/loggers/logger_syslog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ Options:
* `tls-support`: (boolean) enable tls
* `tls-insecure`: (boolean) insecure skip verify
* `tls-min-version`: (string) min tls version, default to 1.2
* `format`: (string) Set syslog formatter between `unix` (default), [`rfc3164`](https://www.rfc-editor.org/rfc/)rfc3164 ) or [`rfc5424`](https://www.rfc-editor.org/rfc/rfc5424)
* `format`: (string) Set syslog formatter between `unix` (default), [`rfc3164`](https://www.rfc-editor.org/rfc/)rfc3164 or [`rfc5424`](https://www.rfc-editor.org/rfc/rfc5424)
* `chan-buffer-size`: (integer) channel buffer size used on incoming dns message, number of messages before to drop it.
* `tag`: (string) syslog tag

Default values:

Expand All @@ -36,4 +37,5 @@ syslog:
tls-min-version: 1.2
format: ""
chan-buffer-size: 65535
tag: ""
```
7 changes: 5 additions & 2 deletions loggers/syslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,16 @@ func (o *Syslog) Process() {
tlsConfig.MinVersion = dnsutils.TLS_VERSION[o.config.Loggers.Syslog.TlsMinVersion]

syslogconn, err = syslog.DialWithTLSConfig(o.config.Loggers.Syslog.Transport,
o.config.Loggers.Syslog.RemoteAddress, o.facility|o.severity, "", tlsConfig)
o.config.Loggers.Syslog.RemoteAddress, o.facility|o.severity,
o.config.Loggers.Syslog.Tag,
tlsConfig)
if err != nil {
o.logger.Fatal("failed to connect to the remote tls syslog:", err)
}
} else {
syslogconn, err = syslog.Dial(o.config.Loggers.Syslog.Transport,
o.config.Loggers.Syslog.RemoteAddress, o.facility|o.severity, "")
o.config.Loggers.Syslog.RemoteAddress, o.facility|o.severity,
o.config.Loggers.Syslog.Tag)
if err != nil {
o.logger.Fatal("failed to connect to the remote syslog:", err)
}
Expand Down

0 comments on commit ff45517

Please sign in to comment.