Blob Blame History Raw
From d9779382a7d06499fb487b50f5ea896f30db7bab Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 3 Apr 2012 18:15:28 +0200
Subject: [PATCH] journal: in json and export mode use double underscores to
 prefix location fields

Many programming languages don't allow variable names beginning in dots,
hence let's use double underscores for the location fields instead. This
gets us the simple rule:

__ is the prefix for location fields (i.e. fields that are used to
identify entries, rather than part of the entries)

_ is the prefix for trusted fields (i.e. those fields journald itself
adds to all entries)

no prefix for unrusted fields (i.e. all fields normal client code sends
us)
(cherry picked from commit ba8d3790e85ce6bacb2e567e0ba48ceb8e66770e)
---
 src/logs-show.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/logs-show.c b/src/logs-show.c
index f71c6b0..0a07a77 100644
--- a/src/logs-show.c
+++ b/src/logs-show.c
@@ -347,10 +347,10 @@ static int output_export(sd_journal *j, unsigned line, unsigned n_columns, bool
                 return r;
         }
 
-        printf(".cursor=%s\n"
-               ".realtime=%llu\n"
-               ".monotonic=%llu\n"
-               ".boot_id=%s\n",
+        printf("__CURSOR=%s\n"
+               "__REALTIME=%llu\n"
+               "__MONOTONIC=%llu\n"
+               "__BOOT_ID=%s\n",
                cursor,
                (unsigned long long) realtime,
                (unsigned long long) monotonic,
@@ -459,10 +459,10 @@ static int output_json(sd_journal *j, unsigned line, unsigned n_columns, bool sh
                 fputs(",\n", stdout);
 
         printf("{\n"
-               "\t\".cursor\" : \"%s\",\n"
-               "\t\".realtime\" : %llu,\n"
-               "\t\".monotonic\" : %llu,\n"
-               "\t\".boot_id\" : \"%s\"",
+               "\t\"__CURSOR\" : \"%s\",\n"
+               "\t\"__REALTIME\" : \"%llu\",\n"
+               "\t\"__MONOTONIC\" : \"%llu\",\n"
+               "\t\"__BOOT_ID\" : \"%s\"",
                cursor,
                (unsigned long long) realtime,
                (unsigned long long) monotonic,