#include "collectd.h"
-#include "common.h"
#include "plugin.h"
+#include "utils/common/common.h"
#include <sys/types.h>
#include <yajl/yajl_common.h>
static pthread_mutex_t file_lock = PTHREAD_MUTEX_INITIALIZER;
-static char *log_file = NULL;
+static char *log_file;
static const char *config_keys[] = {"LogLevel", "File"};
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
static void log_logstash_print(yajl_gen g, int severity,
cdtime_t timestamp_time) {
FILE *fh;
- _Bool do_close = 0;
+ bool do_close = false;
struct tm timestamp_tm;
char timestamp_str[64];
const unsigned char *buf;
fh = stderr;
} else if (strcasecmp(log_file, "stdout") == 0) {
fh = stdout;
- do_close = 0;
+ do_close = false;
} else if (strcasecmp(log_file, "stderr") == 0) {
fh = stderr;
- do_close = 0;
+ do_close = false;
} else {
fh = fopen(log_file, "a");
- do_close = 1;
+ do_close = true;
}
if (fh == NULL) {
- char errbuf[1024];
fprintf(stderr, "log_logstash plugin: fopen (%s) failed: %s\n", log_file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
} else {
fprintf(fh, "%s\n", buf);
if (do_close) {