[systemd-devel] [PATCH 3/3] journalctl: do not ellipsize when using pager

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Mon Jul 16 22:35:08 PDT 2012


If a pager is used, ellipsization is redundant — the pager does
that better by hiding the part that cannot be shown. Pager's advantage
is that the user can press → to view the hidden part of a message,
and then ← to return.
---
 src/journal/journalctl.c | 9 ++++++---
 src/shared/logs-show.c   | 3 ++-
 src/shared/logs-show.h   | 1 +
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index a0e3b39..cf0ec1a 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -303,6 +303,7 @@ int main(int argc, char *argv[]) {
         bool need_seek = false;
         sd_id128_t previous_boot_id;
         bool previous_boot_id_valid = false;
+        bool have_pager;
 
         log_parse_environment();
         log_open();
@@ -382,7 +383,8 @@ int main(int argc, char *argv[]) {
                 goto finish;
         }
 
-        if (!arg_no_pager && !arg_follow) {
+        have_pager = !arg_no_pager && !arg_follow;
+        if (have_pager) {
                 columns();
                 pager_open();
         }
@@ -395,6 +397,8 @@ int main(int argc, char *argv[]) {
         for (;;) {
                 for (;;) {
                         sd_id128_t boot_id;
+                        int flags = (arg_show_all*OUTPUT_SHOW_ALL |
+                                     have_pager*OUTPUT_FULL_WIDTH);
 
                         if (need_seek) {
                                 r = sd_journal_next(j);
@@ -419,8 +423,7 @@ int main(int argc, char *argv[]) {
 
                         line ++;
 
-                        r = output_journal(j, arg_output, line, 0,
-                                           arg_show_all ? OUTPUT_SHOW_ALL : 0);
+                        r = output_journal(j, arg_output, line, 0, flags);
                         if (r < 0)
                                 goto finish;
 
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index bbfb74c..43e42f7 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -225,7 +225,8 @@ static int output_short(sd_journal *j, unsigned line, unsigned n_columns,
         else if (!utf8_is_printable_n(message, message_len)) {
                 char bytes[FORMAT_BYTES_MAX];
                 printf(": [%s blob data]\n", format_bytes(bytes, sizeof(bytes), message_len));
-        } else if (message_len + n < n_columns)
+        } else if ((flags & OUTPUT_FULL_WIDTH) ||
+                   (message_len + n < n_columns))
                 printf(": %.*s\n", (int) message_len, message);
         else if (n < n_columns) {
                 char *e;
diff --git a/src/shared/logs-show.h b/src/shared/logs-show.h
index 44afaf3..2e9cf63 100644
--- a/src/shared/logs-show.h
+++ b/src/shared/logs-show.h
@@ -44,6 +44,7 @@ typedef enum OutputFlags {
         OUTPUT_MONOTONIC_MODE = 1 << 1,
         OUTPUT_FOLLOW = 1 << 2,
         OUTPUT_WARN_CUTOFF = 1 << 3,
+        OUTPUT_FULL_WIDTH = 1 << 4,
 } OutputFlags;
 
 int output_journal(sd_journal *j, OutputMode mode, unsigned line,
-- 
1.7.11.1.282.g511ba53



More information about the systemd-devel mailing list