X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Flog_logstash.c;h=de34b0ea53f78b844cb37cb5ddcadca28d57a847;hp=303976b5a82c5fa0d0ac139e985d00512bb8af2c;hb=a9e50e9e30ecde17e167e271060c8183bfcbf407;hpb=877672d20fcf0ed25f5fc5faa8aa3964c622bc27 diff --git a/src/log_logstash.c b/src/log_logstash.c index 303976b5..de34b0ea 100644 --- a/src/log_logstash.c +++ b/src/log_logstash.c @@ -41,8 +41,6 @@ #define HAVE_YAJL_V2 1 #endif -#define DEFAULT_LOGFILE LOCALSTATEDIR "/log/" PACKAGE_NAME ".json.log" - #if COLLECT_DEBUG static int log_level = LOG_DEBUG; #else @@ -149,8 +147,7 @@ static void log_logstash_print(yajl_gen g, int severity, pthread_mutex_lock(&file_lock); if (log_file == NULL) { - fh = fopen(DEFAULT_LOGFILE, "a"); - do_close = 1; + fh = stderr; } else if (strcasecmp(log_file, "stdout") == 0) { fh = stdout; do_close = 0; @@ -163,10 +160,8 @@ static void log_logstash_print(yajl_gen g, int severity, } if (fh == NULL) { - char errbuf[1024]; - fprintf(stderr, "log_logstash plugin: fopen (%s) failed: %s\n", - (log_file == NULL) ? DEFAULT_LOGFILE : log_file, - sstrerror(errno, errbuf, sizeof(errbuf))); + fprintf(stderr, "log_logstash plugin: fopen (%s) failed: %s\n", log_file, + STRERRNO); } else { fprintf(fh, "%s\n", buf); if (do_close) { @@ -240,7 +235,7 @@ static int log_logstash_notification(const notification_t *n, if (g == NULL) { fprintf(stderr, "Could not allocate JSON generator.\n"); - return (0); + return 0; } if (yajl_gen_map_open(g) != yajl_gen_status_ok) @@ -327,12 +322,12 @@ static int log_logstash_notification(const notification_t *n, } log_logstash_print(g, LOG_INFO, (n->time != 0) ? n->time : cdtime()); - return (0); + return 0; err: yajl_gen_free(g); fprintf(stderr, "Could not correctly generate JSON notification\n"); - return (0); + return 0; } /* int log_logstash_notification */ void module_register(void) { @@ -343,5 +338,3 @@ void module_register(void) { plugin_register_notification("log_logstash", log_logstash_notification, /* user_data = */ NULL); } /* void module_register (void) */ - -/* vim: set sw=4 ts=4 tw=78 noexpandtab : */