]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: use table_set_json_field_name() to override a column name
authorFrantisek Sumsal <frantisek@sumsal.cz>
Mon, 14 Mar 2022 17:26:53 +0000 (18:26 +0100)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Mon, 14 Mar 2022 22:33:22 +0000 (23:33 +0100)
Pointed out in: https://github.com/systemd/systemd/pull/22721#discussion_r826014227
Follow-up for: 5a1355d848a0f6564a04c6d8268e72bc93d173de

src/journal/journalctl.c

index e0951f9682e1cf5dab81b955ebbe6536db3091e9..55c48eded58554b298034de350800c1e29e739f3 100644 (file)
@@ -1460,13 +1460,17 @@ static int list_boots(sd_journal *j) {
         if (count == 0)
                 return count;
 
-        table = table_new(OUTPUT_MODE_IS_JSON(arg_output) ? "index" : "idx", "boot id", "first entry", "last entry");
+        table = table_new("idx", "boot id", "first entry", "last entry");
         if (!table)
                 return log_oom();
 
         if (arg_full)
                 table_set_width(table, 0);
 
+        r = table_set_json_field_name(table, 0, "index");
+        if (r < 0)
+                return log_error_errno(r, "Failed to set JSON field name of column 0: %m");
+
         i = 0;
         LIST_FOREACH(boot_list, id, all_ids) {
                 r = table_add_many(table,