From 8160b214d70d04bfde66b788ea1a25ec99044cde Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Mon, 30 Jul 2007 22:43:26 +0200 Subject: [PATCH] syslog plugin: Call `openlog' right when the plugin is loaded. --- ChangeLog | 2 ++ src/syslog.c | 14 ++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 25dcc3ee..465701d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ instance' was used to match against the list, but the documentation told otherwise. This release fixes the code, so it complies with the documentation. + * syslog plugin: Call `openlog' right when the plugin is loaded, so + configuration messages will end up in the logging facility. 2007-07-05, Version 4.0.5 * Portability: More fixes for OpenBSD have been included. diff --git a/src/syslog.c b/src/syslog.c index 08dadcb9..a21bef18 100644 --- a/src/syslog.c +++ b/src/syslog.c @@ -28,7 +28,11 @@ # include #endif +#if COLLECT_DEBUG static int log_level = LOG_DEBUG; +#else +static int log_level = LOG_INFO; +#endif /* COLLECT_DEBUG */ static const char *config_keys[] = { @@ -64,13 +68,6 @@ static int sl_config (const char *key, const char *value) return (0); } /* int sl_config */ -static int sl_init (void) -{ - openlog ("collectd", LOG_CONS | LOG_PID, LOG_DAEMON); - - return (0); -} - static void sl_log (int severity, const char *msg) { if (severity > log_level) @@ -88,8 +85,9 @@ static int sl_shutdown (void) void module_register (void) { + openlog ("collectd", LOG_CONS | LOG_PID, LOG_DAEMON); + plugin_register_config ("syslog", sl_config, config_keys, config_keys_num); - plugin_register_init ("syslog", sl_init); plugin_register_log ("syslog", sl_log); plugin_register_shutdown ("syslog", sl_shutdown); } /* void module_register(void) */ -- 2.30.2