projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
72ec1d0
)
support emitting to stdout or stderr
author
Pierre-Yves Ritschard
<pyr@spootnik.org>
Fri, 25 Jul 2014 13:59:51 +0000
(15:59 +0200)
committer
Pierre-Yves Ritschard
<pyr@spootnik.org>
Fri, 25 Jul 2014 13:59:51 +0000
(15:59 +0200)
src/log_logstash.c
patch
|
blob
|
history
diff --git
a/src/log_logstash.c
b/src/log_logstash.c
index
14268d2
..
4b7790c
100644
(file)
--- a/
src/log_logstash.c
+++ b/
src/log_logstash.c
@@
-86,7
+86,7
@@
static void log_logstash_print (yajl_gen g, int severity,
size_t len;
#else
unsigned int len;
size_t len;
#else
unsigned int len;
-#endif
+#endif
if (yajl_gen_string(g, (u_char *)"@level", strlen("@level")) !=
yajl_gen_status_ok)
if (yajl_gen_string(g, (u_char *)"@level", strlen("@level")) !=
yajl_gen_status_ok)
@@
-134,13
+134,13
@@
static void log_logstash_print (yajl_gen g, int severity,
tt = CDTIME_T_TO_TIME_T (timestamp_time);
gmtime_r (&tt, ×tamp_tm);
tt = CDTIME_T_TO_TIME_T (timestamp_time);
gmtime_r (&tt, ×tamp_tm);
- /*
+ /*
* format time as a UTC ISO 8601 compliant string
*/
strftime (timestamp_str, sizeof (timestamp_str),
"%Y-%m-%d %H:%M:%SZ", ×tamp_tm);
timestamp_str[sizeof (timestamp_str) - 1] = '\0';
* format time as a UTC ISO 8601 compliant string
*/
strftime (timestamp_str, sizeof (timestamp_str),
"%Y-%m-%d %H:%M:%SZ", ×tamp_tm);
timestamp_str[sizeof (timestamp_str) - 1] = '\0';
-
+
if (yajl_gen_string(g, (u_char *)timestamp_str,
strlen(timestamp_str)) !=
yajl_gen_status_ok)
if (yajl_gen_string(g, (u_char *)timestamp_str,
strlen(timestamp_str)) !=
yajl_gen_status_ok)
@@
-157,9
+157,13
@@
static void log_logstash_print (yajl_gen g, int severity,
{
fh = fopen (DEFAULT_LOGFILE, "a");
do_close = 1;
{
fh = fopen (DEFAULT_LOGFILE, "a");
do_close = 1;
- }
- else
- {
+ } else if (strcasecmp(log_file, "stdout") == 0) {
+ fh = stdout;
+ do_close = 0;
+ } else if (strcasecmp(log_file, "stderr") == 0) {
+ fh = stderr;
+ do_close = 0;
+ } else {
fh = fopen (log_file, "a");
do_close = 1;
}
fh = fopen (log_file, "a");
do_close = 1;
}
@@
-198,7
+202,7
@@
static void log_logstash_log (int severity, const char *msg,
yajl_gen_config conf;
conf.beautify = 0;
yajl_gen_config conf;
conf.beautify = 0;
-#endif
+#endif
if (severity > log_level)
return;
if (severity > log_level)
return;
@@
-229,7
+233,7
@@
static void log_logstash_log (int severity, const char *msg,
yajl_gen_free(g);
fprintf(stderr, "Could not generate JSON message preamble\n");
return;
yajl_gen_free(g);
fprintf(stderr, "Could not generate JSON message preamble\n");
return;
-
+
} /* void log_logstash_log (int, const char *) */
static int log_logstash_notification (const notification_t *n,
} /* void log_logstash_log (int, const char *) */
static int log_logstash_notification (const notification_t *n,
@@
-316,7
+320,7
@@
static int log_logstash_notification (const notification_t *n,
yajl_gen_status_ok)
goto err;
if (yajl_gen_string(g, (u_char *)n->type_instance,
yajl_gen_status_ok)
goto err;
if (yajl_gen_string(g, (u_char *)n->type_instance,
- strlen(n->type_instance)) !=
+ strlen(n->type_instance)) !=
yajl_gen_status_ok)
goto err;
}
yajl_gen_status_ok)
goto err;
}
@@
-379,4
+383,3
@@
void module_register (void)
} /* void module_register (void) */
/* vim: set sw=4 ts=4 tw=78 noexpandtab : */
} /* void module_register (void) */
/* vim: set sw=4 ts=4 tw=78 noexpandtab : */
-