static bool arg_quiet = false;
static bool arg_merge = false;
static bool arg_this_boot = false;
+static const char *arg_cursor = NULL;
static const char *arg_directory = NULL;
static int arg_priorities = 0xFF;
static const char *arg_verify_key = NULL;
" --version Show package version\n"
" --no-pager Do not pipe output into a pager\n"
" -a --all Show all fields, including long and unprintable\n"
+ " -c --cursor=CURSOR Jump to the specified cursor\n"
" -f --follow Follow journal\n"
" -n --lines[=INTEGER] Number of journal entries to show\n"
" --no-tail Show all lines, even in follow mode\n"
{ "verify", no_argument, NULL, ARG_VERIFY },
{ "verify-key", required_argument, NULL, ARG_VERIFY_KEY },
{ "disk-usage", no_argument, NULL, ARG_DISK_USAGE },
+ { "cursor", no_argument, NULL, 'c' },
{ NULL, 0, NULL, 0 }
};
assert(argc >= 0);
assert(argv);
- while ((c = getopt_long(argc, argv, "hfo:an::qmbD:p:", options, NULL)) >= 0) {
+ while ((c = getopt_long(argc, argv, "hfo:an::qmbD:p:c:", options, NULL)) >= 0) {
switch (c) {
arg_directory = optarg;
break;
+ case 'c':
+ arg_cursor = optarg;
+ break;
+
case ARG_HEADER:
arg_action = ACTION_PRINT_HEADER;
break;
int main(int argc, char *argv[]) {
int r;
sd_journal *j = NULL;
- unsigned line = 0;
bool need_seek = false;
sd_id128_t previous_boot_id;
bool previous_boot_id_valid = false;
}
}
- if (arg_lines >= 0) {
+ if (arg_cursor) {
+ r = sd_journal_seek_cursor(j, arg_cursor);
+ if (r < 0) {
+ log_error("Failed to seek to cursor: %s", strerror(-r));
+ goto finish;
+ }
+
+ r = sd_journal_next(j);
+
+ } else if (arg_lines >= 0) {
r = sd_journal_seek_tail(j);
if (r < 0) {
log_error("Failed to seek to tail: %s", strerror(-r));
}
r = sd_journal_previous_skip(j, arg_lines);
+
} else {
r = sd_journal_seek_head(j);
if (r < 0) {
}
}
- line ++;
-
- r = output_journal(j, arg_output, line, 0, flags);
+ r = output_journal(stdout, j, arg_output, 0, flags);
if (r < 0)
goto finish;