X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Flogfile.c;h=a7cda3a1ef44c68df1efdf616a7b6cd25af72a57;hb=f8379dd45f4a43595f4027992696ee8d02908bff;hp=ded7732b00ce22fcc648cbb8ae2207c53f26db94;hpb=76a7816d2c066f2feff5c77e7da58df4dbc982c2;p=collectd.git diff --git a/src/logfile.c b/src/logfile.c index ded7732b..a7cda3a1 100644 --- a/src/logfile.c +++ b/src/logfile.c @@ -54,7 +54,11 @@ static int logfile_config (const char *key, const char *value) { if (0 == strcasecmp (key, "LogLevel")) { log_level = parse_log_severity(value); - if (log_level == -1) return 1; /* to keep previous behaviour */ + if (log_level < 0) { + log_level = LOG_INFO; + ERROR ("logfile: invalid loglevel [%s] defaulting to 'info'", value); + return (1); + } } else if (0 == strcasecmp (key, "File")) { sfree (log_file); @@ -81,7 +85,7 @@ static void logfile_print (const char *msg, int severity, cdtime_t timestamp_time) { FILE *fh; - int do_close = 0; + _Bool do_close = 0; struct tm timestamp_tm; char timestamp_str[64]; char level_str[16] = ""; @@ -151,8 +155,11 @@ static void logfile_print (const char *msg, int severity, else fprintf (fh, "%s%s\n", level_str, msg); - if (do_close != 0) + if (do_close) { fclose (fh); + } else { + fflush(fh); + } } pthread_mutex_unlock (&file_lock); @@ -189,7 +196,7 @@ static int logfile_notification (const notification_t *n, #define APPEND(bufptr, buflen, key, value) \ if ((buflen > 0) && (strlen (value) > 0)) { \ - int status = ssnprintf (bufptr, buflen, ", %s = %s", key, value); \ + status = ssnprintf (bufptr, buflen, ", %s = %s", key, value); \ if (status > 0) { \ bufptr += status; \ buflen -= status; \