src/modules/logwatch.c
changeset 135 9159bd51525f
parent 134 978041c1c04d
child 138 a716c621cb90
--- a/src/modules/logwatch.c	Sun Apr 12 18:35:16 2009 +0300
+++ b/src/modules/logwatch.c	Sun Apr 12 18:56:51 2009 +0300
@@ -112,18 +112,24 @@
     format      = config_get_string     (option, values, "format"   );
     irc_chan    = config_get_irc_chan   (option, values, "chan"     );
 
-    // lookup name
+    // replace old filter?
+    if ((filter = logwatch_filter_lookup(ctx, name))) {
+        log_info("removing old filter: %s: %p", name, filter);
+        logwatch_filter_destroy(filter);
+    }
+
+    // lookup source
     if (source_name && (source = logwatch_source_lookup(ctx, source_name)) == NULL)
        RETURN_SET_ERROR_STR(err, ERR_MODULE_CONF, "unknown logwatch_source name");
     
-    // lookup the channel
+    // lookup channel
     if ((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",
         name, source_name, pattern, format, irc_chan_name(irc_chan));
 
-    // invoke
+    // create a new one
     if ((filter = logwatch_filter(ctx, name, source, pattern, format, chan, err)) == NULL)
         goto error;
 
@@ -146,7 +152,8 @@
 
     CONFIG_OPT(         "filter",       logwatch_conf_filter, 
         "filter lines from source (or all), using the given regular expression (or all lines), and format output "
-        "using the given format expression (or pass through directly), and finally send the output to the given channel",
+        "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    ),