BUG/MINOR: cli/stats: add missing trailing LF after "show info json"
This is the continuation of commit 5a0e7ca5d ("BUG/MINOR: cli/stats: add
missing trailing LF after JSON outputs"). There's also a "show info json"
command which was also missing the trailing LF. It's constructed exactly
like the "show stat json", in that it dumps a series of fields without any
LF. The difference however is that for the stats output, everything was
enclosed in an array which required an LF *after* the closing bracket,
while here there's no such array so we have to emit the LF after the loop.
That makes the two functions a bit inconsistent, it's quite annoying, but
making them better would require sending one LF per line in the stats
output, which is not particularly interesting.
Given that it took 5+ years to spot that this code wasn't working as
expected it doesn't seem worth investing much time trying to refactor
it to make it look cleaner at the risk of breaking other obscure parts.
(cherry picked from commit c6b7a97e5465e0d220ff5555cd88bab7bc5e4f5c)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 63c7a390bcfc3a30244b3ffa0fb6092370c1ce41)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 802fb57e8e30a271ae18895fe21aa27a8c73d770)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/stats.c b/src/stats.c
index 67385a5..370c169 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -688,13 +688,13 @@
goto err;
}
- if (!chunk_strcat(out, "]"))
+ if (!chunk_strcat(out, "]\n"))
goto err;
return 1;
err:
chunk_reset(out);
- chunk_appendf(out, "{\"errorStr\":\"output buffer too short\"}");
+ chunk_appendf(out, "{\"errorStr\":\"output buffer too short\"}\n");
return 0;
}