summaryrefslogtreecommitdiff
path: root/src/grp-journal/journalctl
diff options
context:
space:
mode:
Diffstat (limited to 'src/grp-journal/journalctl')
-rw-r--r--src/grp-journal/journalctl/journalctl.c37
-rw-r--r--src/grp-journal/journalctl/journalctl.completion.bash2
-rw-r--r--src/grp-journal/journalctl/journalctl.completion.zsh37
-rw-r--r--src/grp-journal/journalctl/journalctl.xml47
4 files changed, 83 insertions, 40 deletions
diff --git a/src/grp-journal/journalctl/journalctl.c b/src/grp-journal/journalctl/journalctl.c
index 4317c05b33..9e31283c0e 100644
--- a/src/grp-journal/journalctl/journalctl.c
+++ b/src/grp-journal/journalctl/journalctl.c
@@ -299,9 +299,9 @@ static void help(void) {
" -n --lines[=INTEGER] Number of journal entries to show\n"
" --no-tail Show all lines, even in follow mode\n"
" -r --reverse Show the newest entries first\n"
- " -o --output=STRING Change journal output mode (short, short-iso,\n"
- " short-precise, short-monotonic, verbose,\n"
- " export, json, json-pretty, json-sse, cat)\n"
+ " -o --output=STRING Change journal output mode (short, short-precise,\n"
+ " short-iso, short-full, short-monotonic, short-unix,\n"
+ " verbose, export, json, json-pretty, json-sse, cat)\n"
" --utc Express time in Coordinated Universal Time (UTC)\n"
" -x --catalog Add message explanations where available\n"
" --no-full Ellipsize fields\n"
@@ -312,7 +312,7 @@ static void help(void) {
" -m --merge Show entries from all available journals\n"
" -D --directory=PATH Show journal files from directory\n"
" --file=PATH Show journal file\n"
- " --root=ROOT Operate on catalog files below a root directory\n"
+ " --root=ROOT Operate on files below a root directory\n"
#ifdef HAVE_GCRYPT
" --interval=TIME Time interval for changing the FSS sealing key\n"
" --verify-key=KEY Specify FSS verification key\n"
@@ -850,8 +850,8 @@ static int parse_argv(int argc, char *argv[]) {
if (arg_follow && !arg_no_tail && !arg_since && arg_lines == ARG_LINES_DEFAULT)
arg_lines = 10;
- if (!!arg_directory + !!arg_file + !!arg_machine > 1) {
- log_error("Please specify either -D/--directory= or --file= or -M/--machine=, not more than one.");
+ if (!!arg_directory + !!arg_file + !!arg_machine + !!arg_root > 1) {
+ log_error("Please specify at most one of -D/--directory=, --file=, -M/--machine=, --root.");
return -EINVAL;
}
@@ -1093,8 +1093,10 @@ static int discover_next_boot(sd_journal *j,
r = sd_journal_previous(j);
if (r < 0)
return r;
- else if (r == 0)
+ else if (r == 0) {
+ log_debug("Whoopsie! We found a boot ID but can't read its last entry.");
return -ENODATA; /* This shouldn't happen. We just came from this very boot ID. */
+ }
r = sd_journal_get_realtime_usec(j, &next_boot->last);
if (r < 0)
@@ -1114,7 +1116,7 @@ static int get_boots(
bool skip_once;
int r, count = 0;
- BootId *head = NULL, *tail = NULL;
+ BootId *head = NULL, *tail = NULL, *id;
const bool advance_older = boot_id && offset <= 0;
sd_id128_t previous_boot_id;
@@ -1205,6 +1207,13 @@ static int get_boots(
break;
}
} else {
+ LIST_FOREACH(boot_list, id, head) {
+ if (sd_id128_equal(id->id, current->id)) {
+ /* boot id already stored, something wrong with the journal files */
+ /* exiting as otherwise this problem would cause forever loop */
+ goto finish;
+ }
+ }
LIST_INSERT_AFTER(boot_list, head, tail, current);
tail = current;
current = NULL;
@@ -1269,7 +1278,7 @@ static int add_boot(sd_journal *j) {
* We can do this only when we logs are coming from the current machine,
* so take the slow path if log location is specified. */
if (arg_boot_offset == 0 && sd_id128_is_null(arg_boot_id) &&
- !arg_directory && !arg_file)
+ !arg_directory && !arg_file && !arg_root)
return add_match_this_boot(j, arg_machine);
@@ -1634,7 +1643,7 @@ static int setup_keys(void) {
n /= arg_interval;
safe_close(fd);
- fd = mkostemp_safe(k, O_WRONLY|O_CLOEXEC);
+ fd = mkostemp_safe(k);
if (fd < 0) {
r = log_error_errno(fd, "Failed to open %s: %m", k);
goto finish;
@@ -1686,9 +1695,9 @@ static int setup_keys(void) {
"at a safe location and should not be saved locally on disk.\n"
"\n\t%s",
ansi_highlight(), ansi_normal(),
+ p,
ansi_highlight(), ansi_normal(),
- ansi_highlight_red(),
- p);
+ ansi_highlight_red());
fflush(stderr);
}
for (i = 0; i < seed_size; i++) {
@@ -2163,6 +2172,8 @@ int main(int argc, char *argv[]) {
if (arg_directory)
r = sd_journal_open_directory(&j, arg_directory, arg_journal_type);
+ else if (arg_root)
+ r = sd_journal_open_directory(&j, arg_root, arg_journal_type | SD_JOURNAL_OS_ROOT);
else if (arg_file_stdin) {
int ifd = STDIN_FILENO;
r = sd_journal_open_files_fd(&j, &ifd, 1, 0);
@@ -2257,7 +2268,7 @@ int main(int argc, char *argv[]) {
if (r < 0)
goto finish;
- printf("Archived and active journals take up %s on disk.\n",
+ printf("Archived and active journals take up %s in the file system.\n",
format_bytes(sbytes, sizeof(sbytes), bytes));
goto finish;
}
diff --git a/src/grp-journal/journalctl/journalctl.completion.bash b/src/grp-journal/journalctl/journalctl.completion.bash
index 53bedcd92e..a999a10df1 100644
--- a/src/grp-journal/journalctl/journalctl.completion.bash
+++ b/src/grp-journal/journalctl/journalctl.completion.bash
@@ -65,7 +65,7 @@ _journalctl() {
compopt -o filenames
;;
--output|-o)
- comps='short short-iso short-precise short-monotonic verbose export json json-pretty json-sse cat'
+ comps='short short-full short-iso short-precise short-monotonic short-unix verbose export json json-pretty json-sse cat'
;;
--field|-F)
comps=$(journalctl --fields | sort 2>/dev/null)
diff --git a/src/grp-journal/journalctl/journalctl.completion.zsh b/src/grp-journal/journalctl/journalctl.completion.zsh
index 2bee23b6d3..ef67fcf2a0 100644
--- a/src/grp-journal/journalctl/journalctl.completion.zsh
+++ b/src/grp-journal/journalctl/journalctl.completion.zsh
@@ -23,7 +23,7 @@ _list_fields() {
_journal_none() {
local -a _commands _files _jrnl_none
# Setting use-cache will slow this down considerably
- _commands=( ${"$(_call_program commands "$service" -F _EXE 2>/dev/null)"} )
+ _commands=( ${"$(_call_program commands "$service $_sys_service_mgr -F _EXE" 2>/dev/null)"} )
_jrnl_none='yes'
_alternative : \
'files:/dev files:_files -W /dev -P /dev/' \
@@ -33,7 +33,7 @@ _journal_none() {
_journal_fields() {
local -a _fields cmd
- cmd=("journalctl" "-F ${@[-1]}" "2>/dev/null" )
+ cmd=("journalctl $_sys_service_mgr" "-F ${@[-1]}" "2>/dev/null" )
_fields=$(_call_program fields $cmd[@])
_fields=${_fields//'\'/'\\'}
_fields=${_fields//':'/'\:'}
@@ -51,6 +51,31 @@ _journal_boots() {
"bootid:boot ids:compadd -a _bootid"
}
+# Build arguments for "journalctl" to be used in completion.
+# Use both --user and --system modes, they are not exclusive.
+local -a _modes; _modes=(--user --system)
+local -a _modes_with_arg; _modes_with_arg=(--directory -D --file -M --machine --root)
+typeset -a _sys_service_mgr
+local w k v i=0 n=$#words
+while (( i++ < n )); do
+ w=$words[$i]
+ if (( $_modes[(I)$w] )); then
+ _sys_service_mgr+=($w)
+ else
+ # Handle options with arguments. "--key=value" and "--key value".
+ k=${w%%=*}
+ if (( ${_modes_with_arg[(I)$k]} )); then
+ v=${w#*=}
+ if [[ "$k" != "$w" ]]; then
+ # "--key=value" style.
+ _sys_service_mgr+=($w)
+ else
+ # "--key value" style.
+ _sys_service_mgr+=($w ${words[((++i))]})
+ fi
+ fi
+ fi
+done
_arguments -s \
{-h,--help}'[Show this help]' \
'--version[Show package version]' \
@@ -80,10 +105,10 @@ _arguments -s \
{-F,--field=}'[List all values a certain field takes]:Fields:_list_fields' \
'--system[Show system and kernel messages]' \
'--user[Show messages from user services]' \
- {-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \
- {-D+,--directory=}'[Show journal files from directory]:directories:_directories' \
- '--file=[Operate on specified journal files]:file:_files' \
- '--root=[Operate on catalog hierarchy under specified directory]:directories:_directories' \
+ '(--directory -D -M --machine --root --file)'{-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \
+ '(--directory -D -M --machine --root --file)'{-D+,--directory=}'[Show journal files from directory]:directories:_directories' \
+ '(--directory -D -M --machine --root --file)''--root=[Operate on catalog hierarchy under specified directory]:directories:_directories' \
+ '(--directory -D -M --machine --root)--file=[Operate on specified journal files]:file:_files' \
'--new-id128[Generate a new 128 Bit ID]' \
'--header[Show journal header information]' \
'--disk-usage[Show total disk usage]' \
diff --git a/src/grp-journal/journalctl/journalctl.xml b/src/grp-journal/journalctl/journalctl.xml
index e77621d7b3..63b4a267b8 100644
--- a/src/grp-journal/journalctl/journalctl.xml
+++ b/src/grp-journal/journalctl/journalctl.xml
@@ -250,6 +250,18 @@
<varlistentry>
<term>
+ <option>short-full</option>
+ </term>
+ <listitem>
+ <para>is very similar, but shows timestamps in the format the <option>--since=</option> and
+ <option>--until=</option> options accept. Unlike the timestamp information shown in
+ <option>short</option> output mode this mode includes weekday, year and timezone information in the
+ output, and is locale-independent.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
<option>short-iso</option>
</term>
<listitem>
@@ -572,24 +584,17 @@
<term><option>-U</option></term>
<term><option>--until=</option></term>
- <listitem><para>Start showing entries on or newer than the
- specified date, or on or older than the specified date,
- respectively. Date specifications should be of the format
- <literal>2012-10-30 18:17:16</literal>. If the time part is
- omitted, <literal>00:00:00</literal> is assumed. If only the
- seconds component is omitted, <literal>:00</literal> is
- assumed. If the date component is omitted, the current day is
- assumed. Alternatively the strings
- <literal>yesterday</literal>, <literal>today</literal>,
- <literal>tomorrow</literal> are understood, which refer to
- 00:00:00 of the day before the current day, the current day,
- or the day after the current day,
- respectively. <literal>now</literal> refers to the current
- time. Finally, relative times may be specified, prefixed with
- <literal>-</literal> or <literal>+</literal>, referring to
- times before or after the current time, respectively. For complete
- time and date specification, see
- <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
+ <listitem><para>Start showing entries on or newer than the specified date, or on or older than the specified
+ date, respectively. Date specifications should be of the format <literal>2012-10-30 18:17:16</literal>. If the
+ time part is omitted, <literal>00:00:00</literal> is assumed. If only the seconds component is omitted,
+ <literal>:00</literal> is assumed. If the date component is omitted, the current day is assumed. Alternatively
+ the strings <literal>yesterday</literal>, <literal>today</literal>, <literal>tomorrow</literal> are understood,
+ which refer to 00:00:00 of the day before the current day, the current day, or the day after the current day,
+ respectively. <literal>now</literal> refers to the current time. Finally, relative times may be specified,
+ prefixed with <literal>-</literal> or <literal>+</literal>, referring to times before or after the current
+ time, respectively. For complete time and date specification, see
+ <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>. Note that
+ <option>--output=short-full</option> prints timestamps that follow precisely this format.
</para>
</listitem>
</varlistentry>
@@ -654,10 +659,12 @@
<term><option>--root=<replaceable>ROOT</replaceable></option></term>
<listitem><para>Takes a directory path as an argument. If
- specified, journalctl will operate on catalog file hierarchy
+ specified, journalctl will operate on journal directories and catalog file hierarchy
underneath the specified directory instead of the root
directory (e.g. <option>--update-catalog</option> will create
- <filename><replaceable>ROOT</replaceable>/var/lib/systemd/catalog/database</filename>).
+ <filename><replaceable>ROOT</replaceable>/var/lib/systemd/catalog/database</filename>,
+ and journal files under <filename><replaceable>ROOT</replaceable>/run/journal</filename>
+ or <filename><replaceable>ROOT</replaceable>/var/log/journal</filename> will be displayed).
</para></listitem>
</varlistentry>