X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fsyslog.c;h=b4e2c0cfc159916c315bd6239f4bb437c9bc11de;hb=835a58c09ff7afd44627915c9274b16c5df0fb50;hp=6d326ff1b19bd4699c85073bfc557c0e8efbae04;hpb=eec0cd9ca51c5c132ed09fc4699c02f3bd12d748;p=collectd.git diff --git a/src/syslog.c b/src/syslog.c index 6d326ff1..b4e2c0cf 100644 --- a/src/syslog.c +++ b/src/syslog.c @@ -26,8 +26,8 @@ #include "collectd.h" -#include "common.h" #include "plugin.h" +#include "utils/common/common.h" #if HAVE_SYSLOG_H #include @@ -38,10 +38,11 @@ static int log_level = LOG_DEBUG; #else static int log_level = LOG_INFO; #endif /* COLLECT_DEBUG */ -static int notif_severity = 0; +static int notif_severity; static const char *config_keys[] = { - "LogLevel", "NotifyLevel", + "LogLevel", + "NotifyLevel", }; static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); @@ -51,15 +52,17 @@ static int sl_config(const char *key, const char *value) { if (log_level < 0) { log_level = LOG_INFO; ERROR("syslog: invalid loglevel [%s] defaulting to 'info'", value); - return (1); + return 1; } } else if (strcasecmp(key, "NotifyLevel") == 0) { notif_severity = parse_notif_severity(value); - if (notif_severity < 0) - return (1); + if (notif_severity < 0) { + ERROR("syslog: invalid notification severity [%s]", value); + return 1; + } } - return (0); + return 0; } /* int sl_config */ static void sl_log(int severity, const char *msg, @@ -73,7 +76,7 @@ static void sl_log(int severity, const char *msg, static int sl_shutdown(void) { closelog(); - return (0); + return 0; } static int sl_notification(const notification_t *n, @@ -85,7 +88,7 @@ static int sl_notification(const notification_t *n, int status; if (n->severity > notif_severity) - return (0); + return 0; switch (n->severity) { case NOTIF_FAILURE: @@ -107,11 +110,11 @@ static int sl_notification(const notification_t *n, #define BUFFER_ADD(...) \ do { \ - status = ssnprintf(&buf[offset], sizeof(buf) - offset, __VA_ARGS__); \ + status = snprintf(&buf[offset], sizeof(buf) - offset, __VA_ARGS__); \ if (status < 1) \ - return (-1); \ + return -1; \ else if (((size_t)status) >= (sizeof(buf) - offset)) \ - return (-ENOMEM); \ + return -ENOMEM; \ else \ offset += ((size_t)status); \ } while (0) @@ -137,7 +140,7 @@ static int sl_notification(const notification_t *n, sl_log(log_severity, buf, NULL); - return (0); + return 0; } /* int sl_notification */ void module_register(void) {