diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-01-04 15:27:31 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-01-04 15:27:31 +0100 |
commit | e91af489a25e8bb65016a63f533ae28a505119ef (patch) | |
tree | 4330d24e9cbb30a90e25919242b8d10891ac985f /src/journal/journalctl.c | |
parent | 6f003b43043da7b57c0ebe15b86856c8248fea4a (diff) |
journalctl: only output 10 most recent lines in --follow mode
Diffstat (limited to 'src/journal/journalctl.c')
-rw-r--r-- | src/journal/journalctl.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 0e1fb66de6..e888990f23 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -38,11 +38,11 @@ #include "logs-show.h" static output_mode arg_output = OUTPUT_SHORT; - static bool arg_follow = false; static bool arg_show_all = false; static bool arg_no_pager = false; static int arg_lines = -1; +static bool arg_no_tail = false; static int help(void) { @@ -54,6 +54,7 @@ static int help(void) { " -a --all Show all properties, including long and unprintable\n" " -f --follow Follow journal\n" " -n --lines=INTEGER Lines to show\n" + " --no-tail Show all lines, even in follow mode\n" " -o --output=STRING Change output mode (short, verbose, export, json)\n", program_invocation_short_name); @@ -64,7 +65,8 @@ static int parse_argv(int argc, char *argv[]) { enum { ARG_VERSION = 0x100, - ARG_NO_PAGER + ARG_NO_PAGER, + ARG_NO_TAIL }; static const struct option options[] = { @@ -75,6 +77,7 @@ static int parse_argv(int argc, char *argv[]) { { "output", required_argument, NULL, 'o' }, { "all", no_argument, NULL, 'a' }, { "lines", required_argument, NULL, 'n' }, + { "no-tail", no_argument, NULL, ARG_NO_TAIL }, { NULL, 0, NULL, 0 } }; @@ -126,12 +129,16 @@ static int parse_argv(int argc, char *argv[]) { case 'n': r = safe_atoi(optarg, &arg_lines); - if (r < 0) { + if (r < 0 || arg_lines < 0) { log_error("Failed to parse lines '%s'", optarg); return -EINVAL; } break; + case ARG_NO_TAIL: + arg_no_tail = true; + break; + case '?': return -EINVAL; @@ -141,6 +148,9 @@ static int parse_argv(int argc, char *argv[]) { } } + if (arg_follow && !arg_no_tail) + arg_lines = 10; + return 1; } |