remote_syslog2
remote_syslog2 copied to clipboard
Create an includes_patterns for explicit log lines
There are situations where we dont want the entire log file, (catalina/tomcat) to dump into remote syslog.
I know there was a previous issue thar was complicated, but this could just be implemented with a config that fails if both includes_patterns and excludes_patterns both exist to at least add value.
type Config struct {
[..]
IncludePatterns []*regexp.Regexp `mapstructure:"include_patterns"`
[..]
}
if ( s.config.IncludePatterns blah blah is set )
{
if matchExps(l, s.config.IncludePatterns) {
s.logger.Write(syslog.Packet{
Severity: s.config.Severity,
Facility: s.config.Facility,
Time: time.Now(),
Hostname: s.logger.ClientHostname,
Tag: tag,
Message: l,
})
log.Tracef("Forwarding line: %s", l)
} else {
log.Tracef("Not Forwarding line: %s", l)
}
}
else
{
if !matchExps(l, s.config.ExcludePatterns) {
s.logger.Write(syslog.Packet{
Severity: s.config.Severity,
Facility: s.config.Facility,
Time: time.Now(),
Hostname: s.logger.ClientHostname,
Tag: tag,
Message: l,
})
log.Tracef("Forwarding line: %s", l)
} else {
log.Tracef("Not Forwarding line: %s", l)
}
}