summaryrefslogtreecommitdiffstats
path: root/src/shared/output-mode.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-12-03 20:40:02 +0100
committerLennart Poettering <lennart@poettering.net>2018-12-03 22:42:38 +0100
commit9e964bb8e472174fe680a478167ed20a8f2515a4 (patch)
treeba9553fa7662b40eb191334a7fd68d61e66794aa /src/shared/output-mode.c
parentjson: add new display flag JSON_FORMAT_COLOR_AUTO (diff)
downloadsystemd-9e964bb8e472174fe680a478167ed20a8f2515a4.tar.xz
systemd-9e964bb8e472174fe680a478167ed20a8f2515a4.zip
output-mode: add generic helper to pick right JsonFormatFlags for given OutputMode
Diffstat (limited to 'src/shared/output-mode.c')
-rw-r--r--src/shared/output-mode.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/shared/output-mode.c b/src/shared/output-mode.c
index 9463d185f0..107b345538 100644
--- a/src/shared/output-mode.c
+++ b/src/shared/output-mode.c
@@ -3,6 +3,24 @@
#include "output-mode.h"
#include "string-table.h"
+JsonFormatFlags output_mode_to_json_format_flags(OutputMode m) {
+
+ switch (m) {
+
+ case OUTPUT_JSON_SSE:
+ return JSON_FORMAT_SSE;
+
+ case OUTPUT_JSON_SEQ:
+ return JSON_FORMAT_SEQ;
+
+ case OUTPUT_JSON_PRETTY:
+ return JSON_FORMAT_PRETTY;
+
+ default:
+ return JSON_FORMAT_NEWLINE;
+ }
+}
+
static const char *const output_mode_table[_OUTPUT_MODE_MAX] = {
[OUTPUT_SHORT] = "short",
[OUTPUT_SHORT_FULL] = "short-full",