Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an includes_patterns for explicit log lines #220

Open
shadowbq opened this issue Oct 30, 2018 · 1 comment
Open

Create an includes_patterns for explicit log lines #220

shadowbq opened this issue Oct 30, 2018 · 1 comment

Comments

@shadowbq
Copy link

shadowbq commented Oct 30, 2018

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.

@shadowbq
Copy link
Author

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)
            }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant