[syslog-ng] [PATCH] syslog-ng: Add a -q/--silent-module-load option

Gergely Nagy algernon at balabit.hu
Sat Oct 15 10:59:53 CEST 2011


With the -q/--silent-module-load option set (defaults to off), no
warnings will be printed when a module cannot be found.

If it's found, but cannot be loaded, a message is still printed. If it
is used later in the config, that's still handled correctly.

The flag only suppresses the warning, and nothing else.

Signed-off-by: Gergely Nagy <algernon at balabit.hu>
---
 lib/globals.c    |    1 +
 lib/plugin.c     |    9 +++++----
 lib/syslog-ng.h  |    1 +
 syslog-ng/main.c |    1 +
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/globals.c b/lib/globals.c
index b2afec7..b3b2121 100644
--- a/lib/globals.c
+++ b/lib/globals.c
@@ -28,3 +28,4 @@ GlobalConfig *configuration;
 int cfg_parser_debug;
 gchar *module_path = MODULE_PATH;
 gchar *default_modules = DEFAULT_MODULES;
+gboolean silent_module_load = FALSE;
diff --git a/lib/plugin.c b/lib/plugin.c
index 5239974..cce549a 100644
--- a/lib/plugin.c
+++ b/lib/plugin.c
@@ -179,10 +179,11 @@ plugin_dlopen_module(const gchar *module_name, const gchar *module_path)
   g_strfreev(module_path_dirs);
   if (!plugin_module_name)
     {
-      msg_error("Plugin module not found in 'module-path'",
-                evt_tag_str("module-path", module_path),
-                evt_tag_str("module", module_name),
-                NULL);
+      if (!silent_module_load)
+	msg_error("Plugin module not found in 'module-path'",
+		  evt_tag_str("module-path", module_path),
+		  evt_tag_str("module", module_name),
+		  NULL);
       return NULL;
     }
   msg_debug("Trying to open module",
diff --git a/lib/syslog-ng.h b/lib/syslog-ng.h
index 4bd79c2..edb8a4d 100644
--- a/lib/syslog-ng.h
+++ b/lib/syslog-ng.h
@@ -66,5 +66,6 @@ typedef struct _GlobalConfig GlobalConfig;
 extern GlobalConfig *configuration;
 extern gchar *module_path;
 extern gchar *default_modules;
+extern gboolean silent_module_load;
 
 #endif
diff --git a/syslog-ng/main.c b/syslog-ng/main.c
index c682e44..e414321 100644
--- a/syslog-ng/main.c
+++ b/syslog-ng/main.c
@@ -75,6 +75,7 @@ static GOptionEntry syslogng_options[] =
   { "module-registry",     0,         0, G_OPTION_ARG_NONE, &display_module_registry, "Display module information", NULL },
   { "default-modules",     0,         0, G_OPTION_ARG_STRING, &default_modules, "Set the set of auto-loaded modules, default=" DEFAULT_MODULES, "<module-list>" },
   { "seed",              'S',         0, G_OPTION_ARG_NONE, &dummy, "Does nothing, the need to seed the random generator is autodetected", NULL},
+  { "silent-module-load", 'q',        0, G_OPTION_ARG_NONE, &silent_module_load, "Load modules silently, not printing a warning when one's not found", NULL},
 #ifdef YYDEBUG
   { "yydebug",           'y',         0, G_OPTION_ARG_NONE, &cfg_parser_debug, "Enable configuration parser debugging", NULL },
 #endif
-- 
1.7.7




More information about the syslog-ng mailing list