summaryrefslogtreecommitdiff
path: root/src/shared/logs-show.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-10-11 02:37:10 +0200
committerLennart Poettering <lennart@poettering.net>2012-10-11 02:37:10 +0200
commit48383c251185c4596e9098878b28334c69e7bfd9 (patch)
tree008dbe8d4d7f87520b839e0f63e34d7190daca2d /src/shared/logs-show.c
parent33316dbf20d378e15d126d97d0415407853a7fb8 (diff)
journal: support epxorting the journal in a format suitable for text/event-stream
Diffstat (limited to 'src/shared/logs-show.c')
-rw-r--r--src/shared/logs-show.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index 725adb6451..28d12d3d4a 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -502,7 +502,10 @@ static int output_json(
(unsigned long long) realtime,
(unsigned long long) monotonic,
sd_id128_to_string(boot_id, sid));
- else
+ else {
+ if (mode == OUTPUT_JSON_SSE)
+ fputs("data: ", f);
+
fprintf(f,
"{ \"__CURSOR\" : \"%s\", "
"\"__REALTIME_TIMESTAMP\" : \"%llu\", "
@@ -512,6 +515,7 @@ static int output_json(
(unsigned long long) realtime,
(unsigned long long) monotonic,
sd_id128_to_string(boot_id, sid));
+ }
free(cursor);
SD_JOURNAL_FOREACH_DATA(j, data, length) {
@@ -541,6 +545,8 @@ static int output_json(
if (mode == OUTPUT_JSON_PRETTY)
fputs("\n}\n", f);
+ else if (mode == OUTPUT_JSON_SSE)
+ fputs("}\n\n", f);
else
fputs(" }\n", f);
@@ -592,6 +598,7 @@ static int (*output_funcs[_OUTPUT_MODE_MAX])(
[OUTPUT_EXPORT] = output_export,
[OUTPUT_JSON] = output_json,
[OUTPUT_JSON_PRETTY] = output_json,
+ [OUTPUT_JSON_SSE] = output_json,
[OUTPUT_CAT] = output_cat
};
@@ -769,6 +776,7 @@ static const char *const output_mode_table[_OUTPUT_MODE_MAX] = {
[OUTPUT_EXPORT] = "export",
[OUTPUT_JSON] = "json",
[OUTPUT_JSON_PRETTY] = "json-pretty",
+ [OUTPUT_JSON_SSE] = "json-sse",
[OUTPUT_CAT] = "cat"
};