Allow multiple hosts or programs to be named in program
or host specifications, eg: !foo,bar *.* /var/log/only_foo_or_bar.log !-foo,bar *.* /var/log/all_except_foo_or_bar.log Reviewed by: roberto Not objected to by: arch@
This commit is contained in:
parent
3dc7ebf9ff
commit
7ac1f02eed
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=110776
@ -196,6 +196,15 @@ or
|
||||
.Ql !-prog
|
||||
specification will match any message but the ones from that
|
||||
program.
|
||||
Multiple programs may be listed, separated by commas:
|
||||
.Ql !prog1,prog2
|
||||
matches messages from either program, while
|
||||
.Ql !-prog1,prog2
|
||||
matches all messages but those from
|
||||
.Ql prog1
|
||||
or
|
||||
.Ql prog2 .
|
||||
.Pp
|
||||
A
|
||||
.Em hostname
|
||||
specification of the form
|
||||
@ -215,6 +224,9 @@ from any host but the one specified.
|
||||
If the hostname is given as
|
||||
.Ql @ ,
|
||||
the local hostname will be used.
|
||||
As for program specifications, multiple comma-seprarated
|
||||
values may be specified for hostname specifications.
|
||||
.Pp
|
||||
A
|
||||
.Em program
|
||||
or
|
||||
|
@ -764,17 +764,38 @@ static time_t now;
|
||||
*/
|
||||
static int
|
||||
skip_message(const char *name, const char *spec) {
|
||||
const char *s;
|
||||
char prev, next;
|
||||
int exclude = 0;
|
||||
/* Behaviour on explicit match */
|
||||
|
||||
if (spec == NULL)
|
||||
return 0;
|
||||
|
||||
switch (spec[0]) {
|
||||
case '+':
|
||||
return (strcmp(name, spec + 1) != 0);
|
||||
switch (*spec) {
|
||||
case '-':
|
||||
return (strcmp(name, spec + 1) == 0);
|
||||
exclude = 1;
|
||||
/*FALLTHROUGH*/
|
||||
case '+':
|
||||
spec++;
|
||||
break;
|
||||
default:
|
||||
return (strcmp(name, spec) != 0);
|
||||
break;
|
||||
}
|
||||
s = strstr (spec, name);
|
||||
|
||||
if (s != NULL) {
|
||||
prev = (s == spec ? ',' : *(s - 1));
|
||||
next = *(s + strlen (name));
|
||||
|
||||
if (prev == ',' && (next == '\0' || next == ','))
|
||||
/* Explicit match: skip iff the spec is an
|
||||
exclusive one. */
|
||||
return exclude;
|
||||
}
|
||||
|
||||
/* No explicit match for this name: skip the message iff
|
||||
the spec is an inclusive one. */
|
||||
return !exclude;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user