summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-09-05 15:25:32 -0700
committerLennart Poettering <lennart@poettering.net>2012-09-05 15:25:32 -0700
commita6e87e90ede66815989ba2db92a07102a69906fe (patch)
treefb0a5304c033842264760a3efe2b7c869f757131 /src/journal
parent04bc4a3f47074d22035831965e97b0990fcf6f63 (diff)
journalctl: rework JSON output mode
This splits the JSON output mode into different modes: json and json-pretty. The former printing one entry per line, the latter showing JSON objects nicely indented and in multiple lines to make it easier to read for humans.
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/journal-send.c2
-rw-r--r--src/journal/journalctl.c10
2 files changed, 2 insertions, 10 deletions
diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c
index d0f3b725ff..b192f1fb88 100644
--- a/src/journal/journal-send.c
+++ b/src/journal/journal-send.c
@@ -439,7 +439,7 @@ _public_ int sd_journal_stream_fd(const char *identifier, int priority, int leve
memcpy(header, identifier, l);
header[l++] = '\n';
- header[l++] = '\n';
+ header[l++] = '\n'; /* unit id */
header[l++] = '0' + priority;
header[l++] = '\n';
header[l++] = '0' + !!level_prefix;
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 6aff1f1ba3..56a8abea57 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -87,7 +87,7 @@ static int help(void) {
" -n --lines=INTEGER Journal entries to show\n"
" --no-tail Show all lines, even in follow mode\n"
" -o --output=STRING Change journal output mode (short, short-monotonic,\n"
- " verbose, export, json, cat)\n"
+ " verbose, export, json, json-pretty, cat)\n"
" -q --quiet Don't show privilege warning\n"
" -l --local Only local entries\n"
" -b --this-boot Show data only from current boot\n"
@@ -821,11 +821,6 @@ int main(int argc, char *argv[]) {
on_tty();
have_pager = !arg_no_pager && !arg_follow && pager_open();
- if (arg_output == OUTPUT_JSON) {
- fputc('[', stdout);
- fflush(stdout);
- }
-
for (;;) {
for (;;) {
sd_id128_t boot_id;
@@ -874,9 +869,6 @@ int main(int argc, char *argv[]) {
}
}
- if (arg_output == OUTPUT_JSON)
- fputs("\n]\n", stdout);
-
finish:
if (j)
sd_journal_close(j);