From: Florian Forster Date: Thu, 9 Jul 2020 10:29:15 +0000 (+0200) Subject: format_json, format_kairosdb: Don't enable beatification of JSON. X-Git-Tag: 6.0.0-rc0~144^2~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=16895d6cdfa9ee1573dcf344c0d9327a36d1b89a;p=thirdparty%2Fcollectd.git format_json, format_kairosdb: Don't enable beatification of JSON. The code depends on the last character in the buffer being ']'. If "beautification" is enabled, it will add a newline at the end, which breaks the "append" mechanic. --- diff --git a/src/utils/format_json/format_json.c b/src/utils/format_json/format_json.c index 5958b12d7..ceecc745a 100644 --- a/src/utils/format_json/format_json.c +++ b/src/utils/format_json/format_json.c @@ -224,16 +224,11 @@ int format_json_metric_family(strbuf_t *buf, metric_family_t const *fam, if (g == NULL) return -1; #if COLLECT_DEBUG - yajl_gen_config(g, yajl_gen_beautify, 1); yajl_gen_config(g, yajl_gen_validate_utf8, 1); #endif #else /* !HAVE_YAJL_V2 */ yajl_gen_config conf = {0}; -#if COLLECT_DEBUG - conf.beautify = 1; - conf.indentString = " "; -#endif yajl_gen g = yajl_gen_alloc(&conf, NULL); if (g == NULL) return -1; diff --git a/src/utils/format_kairosdb/format_kairosdb.c b/src/utils/format_kairosdb/format_kairosdb.c index 6b7eb2ce1..68d17fd42 100644 --- a/src/utils/format_kairosdb/format_kairosdb.c +++ b/src/utils/format_kairosdb/format_kairosdb.c @@ -76,7 +76,7 @@ static int json_add_string(yajl_gen g, char const *str) /* {{{ */ do { \ int status = (f); \ if (status != 0) { \ - ERROR("format_kairosdb: %s = %d", #f, status); \ + ERROR("format_kairosdb: %s failed with status %d", #f, status); \ return status; \ } \ } while (0) @@ -176,16 +176,11 @@ int format_kairosdb_metric_family(strbuf_t *buf, metric_family_t const *fam, if (g == NULL) return ENOMEM; #if COLLECT_DEBUG - yajl_gen_config(g, yajl_gen_beautify, 1); yajl_gen_config(g, yajl_gen_validate_utf8, 1); #endif #else /* !HAVE_YAJL_V2 */ yajl_gen_config conf = {0}; -#if COLLECT_DEBUG - conf.beautify = 1; - conf.indentString = " "; -#endif yajl_gen g = yajl_gen_alloc(&conf, NULL); if (g == NULL) return ENOMEM;