Re: multilog filtering issues

Daryl Tester <[email protected]> Fri, 05 Dec 2008 15:22:33 +1030
Newsgroups gmane.comp.djb.syslog
Message-ID <[email protected]>
(* Reply to set to avoid auto-spammers *)

richard lucassen wrote:

> Why is this NOT giving output to /tmp/testlog/current:
> 
> echo -e "./aaa.bbb.ccc: success" | multilog -* +*success -*aaa.bbb.ccc*
> /tmp/testlog/
> 
> while this is giving output to /tmp/testlog/current:
> 
> echo -e "./aaa.bbb.ccc: success" | multilog -* +*success
> -*aa.bbb.ccc* /tmp/testlog/

First up, you might want to quote those wildcarded expressions before
the shell does something interesting to them behind your back (like
expand them when you least expect it).

> <quote>
> pattern is a string of stars and non-stars. It matches any concatenation
> of strings matched by all the stars and non-stars in the same order. A
> non-star matches itself. A star before the end of pattern matches any
> string that does not include the next character in pattern. A star at
> the end of pattern matches any string.
> </quote>
> 
> For me, this is a quite cryptic description.

Yes, it is, and I've struggled with it before in the past, currently,
and possibly will in the future (for I am a bear of little brain).

If you're thinking of it as a greedy regular expression (or even a
regular regular expression), then it isn't.  The first character
after the wildcard will match the *first instance* of that character
in the line, so the first 'a' in '-*aa.bbb.ccc' matches aaa.bbb.ccc,
but the remainder of the string doesn't, and the line is allowed.
This has deep consequences - the pattern '+*success' won't match
if the letter 's' occurs anywhere before the string 'uccess'
following it.

i.e. -

Works:  echo "chown: success" | multilog '-*' '+*success' /tmp/log

Doesn't:  echo "fsize: success" | multilog '-*' '+*success' /tmp/log

> Target: I want publicfile to only log "success" lines, except queries
> for "certain.file", which occur every minute, something like this:

You already had this in the first example you provided - or are you
running afoul of the above problem?


-- 
Regards,
  Daryl Tester

"Oh Christmas tree, oh Christmas tree!  From hell's heart I stab at thee."
  -- A very Kaaahn! Christmas