|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From 48382487666af141bb4385ceb5fb73c4147f6141 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: Jan Janssen <medhefgo@web.de>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Sun, 31 Aug 2014 11:12:22 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] journalctl: Allow to disable line cap with --lines=all
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
man/journalctl.xml | 13 +++++++------
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/journal/journalctl.c | 42 +++++++++++++++++++++++-------------------
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
2 files changed, 30 insertions(+), 25 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/man/journalctl.xml b/man/journalctl.xml
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index d4e031619a..acd75a6370 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/man/journalctl.xml
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/man/journalctl.xml
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -189,9 +189,9 @@
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
that the pager will not buffer logs of
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unbounded size. This may be overridden
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
with an explicit <option>-n</option>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- with some other numeric value on the
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- command line. Note that this option is
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- only supported for the
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ with some other numeric value while
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ <option>-nall</option> will disable this cap.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ Note that this option is only supported for the
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
<citerefentry project='man-pages'><refentrytitle>less</refentrytitle><manvolnum>1</manvolnum></citerefentry>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
pager.</para></listitem>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
</varlistentry>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -204,9 +204,10 @@
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
journal events and limit the number of
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
events shown. If
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
<option>--follow</option> is used,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- this option is implied. The argument,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- a positive integer, is optional, and
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- defaults to 10. </para></listitem>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ this option is implied. The argument is
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ a positive integer or <literal>all</literal>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ to disable line limiting. The default value is
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ 10 if no argument is given.</para></listitem>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
</varlistentry>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
<varlistentry>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index f3680d1ce2..d00a815ba9 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/journal/journalctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/journal/journalctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -68,7 +68,7 @@ static bool arg_follow = false;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static bool arg_full = true;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static bool arg_all = false;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static bool arg_no_pager = false;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-static int arg_lines = -1;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+static int arg_lines = -2;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static bool arg_no_tail = false;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static bool arg_quiet = false;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static bool arg_merge = false;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -327,7 +327,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
case 'e':
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
arg_pager_end = true;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (arg_lines < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (arg_lines < -1)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
arg_lines = 1000;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
break;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -366,29 +366,33 @@ static int parse_argv(int argc, char *argv[]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
case 'n':
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (optarg) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = safe_atoi(optarg, &arg_lines);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (r < 0 || arg_lines < 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- log_error("Failed to parse lines '%s'", optarg);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- return -EINVAL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (streq(optarg, "all"))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ arg_lines = -1;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ else {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = safe_atoi(optarg, &arg_lines);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (r < 0 || arg_lines < 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ log_error("Failed to parse lines '%s'", optarg);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return -EINVAL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
} else {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- int n;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ arg_lines = 10;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* Hmm, no argument? Maybe the next
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* word on the command line is
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* supposed to be the argument? Let's
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* see if there is one, and is
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * parsable as a positive
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * integer... */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (optind < argc &&
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- safe_atoi(argv[optind], &n) >= 0 &&
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- n >= 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- arg_lines = n;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- optind++;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- } else
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- arg_lines = 10;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * parsable. */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (optind < argc) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ int n;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (streq(argv[optind], "all")) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ arg_lines = -1;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ optind++;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ } else if (safe_atoi(argv[optind], &n) >= 0 && n >= 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ arg_lines = n;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ optind++;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
break;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -642,7 +646,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_not_reached("Unhandled option");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (arg_follow && !arg_no_tail && arg_lines < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (arg_follow && !arg_no_tail && arg_lines < -1)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
arg_lines = 10;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!!arg_directory + !!arg_file + !!arg_machine > 1) {
|