[systemd-devel] Make journalctl start at the end of the journal by default

Philippe De Swert philippedeswert at gmail.com
Mon Aug 18 06:02:45 PDT 2014


Seems the patch has been scrubbed. Will re-send it later if there is interest 
to have it. Should have used git send-email I guess, but now badly inlined at 
the bottom of this email.

Thank you for your help, but you seem to have misunderstood what I am after.

On 18/08/14 15:08, Ronny Chevalier wrote:
> 2014-08-18 13:46 GMT+02:00 Philippe De Swert <philippedeswert at gmail.com>:
>> Having to often use journalctl it has slowly driven me insane with the
>> default options not matching common use cases.
>> Attached is already a patch to start the journal at the end. Usually people
>> check the logs when something went wrong, and don't care about what happened
>> three weeks ago at the beginning of the log. Yes you can press the "end" key
>> to skip to the end but in some cases that freezes up the console for over a
>> minute.
> There is the --reverse or -r option to show the newest entries first,
> is this what you are looking for ?

No. I want -e as default option, as that is what makes sense to me. And I keep 
hearing the same from lots of people that -e should be default. 

>> Other gripes are --no-pager... way too long to type on a virtual keyboard
>> when you are trying to use the logs old style with common unix
>> utilities. Maybe not having it by default, or introducing a shorter command
>> switch should not be hard to add.
>> And also I would like to see the full logs always by default. Usually after
>> lots of searching you find the offending log entry for the error, only to
>> find out you forgot to pass the right command line options to journalctl and
>> the important bit is cut off.
> There is the --all or -a option for this.
> In the end, you just have to use journalctl -ar

The point is that I think that -a should be default. I can't think of any reason 
to have truncated and mangled logs by default. As it too often happens that you 
forget to add the flag as I just explained, you end up to have do all the 
searching again due to the interesting bit of the log being cut/truncated.

The issue is having to use all those switches. Mainly I get sick of having to type 
journalctl --no-pager -a -e on a virtual keyboard every time on a development 
platform that gets reflashed continuously so having aliases etc is not really a 
workable option. And well and the pager I do sometimes want it and other times I 
don't. Depends on what I want to do.

As I stated I am willing to send patches to fix journalctl default behaviour to match 
common use cases. I know about the switches. My point is that you should not need to 
remember every time to use some switches to get default usable behaviour from journalctl 
when performing a simple basic operation.



>From b4c8bd945bc987edd64702e781daea2caff8eeab Mon Sep 17 00:00:00 2001
From: Philippe De Swert <philippedeswert at gmail.com>
Date: Mon, 18 Aug 2014 14:39:19 +0300
Subject: [PATCH] journalctl : automatically go to the end of the log

Usually we do not care about the beginning of the log, as we want to look
at it when something went wrong. So usually this would be the end. So changing
the end feature into a start feature will cause less typing. (Also jumping to
the end of a log with the end key sometimes takes a considerable amount of time,
so we avoid that issue here too). To restore the old behaviour to start at the
beginning of the log, there is now -s or --pager-start. -e is kept for backwards

Signed-off-by: Philippe De Swert <philippedeswert at gmail.com>
 src/journal/journalctl.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 5c4a71d..67f3a26 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -63,7 +63,7 @@

 static OutputMode arg_output = OUTPUT_SHORT;
-static bool arg_pager_end = false;
+static bool arg_pager_end = true;
 static bool arg_follow = false;
 static bool arg_full = true;
 static bool arg_all = false;
@@ -182,6 +182,7 @@ static void help(void) {
                "     --user-unit=UNIT      Show data only from the specified user session unit\n"
                "  -p --priority=RANGE      Show only messages within the specified priority range\n"
                "  -e --pager-end           Immediately jump to end of the journal in the pager\n"
+               "  -s --pager-start         Start at the beginning of the journal in the pager\n"
                "  -f --follow              Follow the journal\n"
                "  -n --lines[=INTEGER]     Number of journal entries to show\n"
                "     --no-tail             Show all lines, even in follow mode\n"
@@ -255,6 +256,7 @@ static int parse_argv(int argc, char *argv[]) {
                 { "version" ,       no_argument,       NULL, ARG_VERSION        },
                 { "no-pager",       no_argument,       NULL, ARG_NO_PAGER       },
                 { "pager-end",      no_argument,       NULL, 'e'                },
+                { "pager-start",    no_argument,       NULL, 's'                },
                 { "follow",         no_argument,       NULL, 'f'                },
                 { "force",          no_argument,       NULL, ARG_FORCE          },
                 { "output",         required_argument, NULL, 'o'                },
@@ -304,7 +306,7 @@ static int parse_argv(int argc, char *argv[]) {
         assert(argc >= 0);

-        while ((c = getopt_long(argc, argv, "hefo:aln::qmb::kD:p:c:u:F:xrM:", options, NULL)) >= 0)
+        while ((c = getopt_long(argc, argv, "hesfo:aln::qmb::kD:p:c:u:F:xrM:", options, NULL)) >= 0)

                 switch (c) {

@@ -329,6 +331,15 @@ static int parse_argv(int argc, char *argv[]) {


+                case 's':
+                        arg_pager_end = false;
+                        if (arg_lines < 0)
+                                arg_lines = 1000;
+                        break;
                 case 'f':
                         arg_follow = true;

More information about the systemd-devel mailing list