--- a/src/modules/logwatch.c Sun Apr 12 22:19:54 2009 +0300
+++ b/src/modules/logwatch.c Sun Apr 12 23:27:15 2009 +0300
@@ -50,11 +50,17 @@
{
const struct logwatch_filter *filter;
struct error_info err;
+ int ret;
// apply each filter
TAILQ_FOREACH(filter, &ctx->filters, logwatch_filters) {
- if (logwatch_filter_apply(filter, source, line, &err))
+ // apply it
+ if ((ret = logwatch_filter_apply(filter, source, line, &err)) < 0)
log_warn("logwatch_filter_apply(%s, %s, %s): %s", filter->name, source->name, line, error_msg(&err));
+
+ // blackhole?
+ if (ret > 0)
+ break;
}
}
@@ -101,7 +107,7 @@
struct logwatch_filter *filter;
const struct logwatch_source *source = NULL;
- struct logwatch_chan *chan;
+ struct logwatch_chan *chan = NULL;
const char *name, *source_name, *pattern, *format;
struct irc_chan *irc_chan;
@@ -123,7 +129,7 @@
RETURN_SET_ERROR_STR(err, ERR_MODULE_CONF, "unknown logwatch_source name");
// lookup channel
- if ((chan = logwatch_get_chan(ctx, irc_chan)) == NULL)
+ if (irc_chan && (chan = logwatch_get_chan(ctx, irc_chan)) == NULL)
RETURN_SET_ERROR_STR(err, ERR_MODULE_CONF, "logwatch_get_chan failed");
log_info("add filter: name=%s, source=%s, pattern=%s, format=%s, chan=%s",
@@ -155,11 +161,11 @@
"using the given format expression (or pass through directly), and finally send the output to the given channel. "
"If a filter with the same name already exists, it will be replaced.",
- CONFIG_PARAM( "name", CONFIG_STRING, "filter name", false ),
- CONFIG_PARAM( "source", CONFIG_STRING, "optional logwatch_source to use", true ),
- CONFIG_PARAM( "pattern", CONFIG_STRING, "optional regular expression pattern", true ),
- CONFIG_PARAM( "format", CONFIG_STRING, "optional output format", true ),
- CONFIG_PARAM( "chan", CONFIG_IRC_CHAN, "channel to send output to", false )
+ CONFIG_PARAM( "name", CONFIG_STRING, "filter name", false ),
+ CONFIG_PARAM( "source", CONFIG_STRING, "optional logwatch_source to use", true ),
+ CONFIG_PARAM( "pattern", CONFIG_STRING, "optional regular expression pattern", true ),
+ CONFIG_PARAM( "format", CONFIG_STRING, "optional output format", true ),
+ CONFIG_PARAM( "chan", CONFIG_IRC_CHAN, "channel to send output to, or NULL to blackhole", true)
)
);