mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-10-26 17:25:34 +03:00
Add short-iso-precise for journalctl output (#5884)
This adds a short-iso-precise option for journalctl output. It is similar to short-iso, but includes microseconds.
This commit is contained in:
parent
51cf831304
commit
7e563bfc97
@ -270,13 +270,23 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>short-iso-precise</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>as for <option>short-iso</option> but includes full
|
||||
microsecond precision.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>short-precise</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>is very similar, but shows timestamps with full
|
||||
microsecond precision.</para>
|
||||
<para>is very similar, but shows classic syslog timestamps
|
||||
with full microsecond precision.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@ -172,7 +172,7 @@ _systemctl () {
|
||||
comps='full enable-only disable-only'
|
||||
;;
|
||||
--output|-o)
|
||||
comps='short short-full short-iso short-precise short-monotonic short-unix verbose export json
|
||||
comps='short short-full short-iso short-iso-precise short-precise short-monotonic short-unix verbose export json
|
||||
json-pretty json-sse cat'
|
||||
;;
|
||||
--machine|-M)
|
||||
|
@ -1,5 +1,5 @@
|
||||
#autoload
|
||||
|
||||
local -a _output_opts
|
||||
_output_opts=(short short-full short-iso short-precise short-monotonic short-unix verbose export json json-pretty json-sse cat)
|
||||
_output_opts=(short short-full short-iso short-iso-precise short-precise short-monotonic short-unix verbose export json json-pretty json-sse cat)
|
||||
_describe -t output 'output mode' _output_opts || compadd "$@"
|
||||
|
@ -299,8 +299,9 @@ static void help(void) {
|
||||
" --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-precise,\n"
|
||||
" short-iso, short-full, short-monotonic, short-unix,\n"
|
||||
" verbose, export, json, json-pretty, json-sse, cat)\n"
|
||||
" short-iso, short-iso-precise, short-full,\n"
|
||||
" short-monotonic, short-unix, verbose, export,\n"
|
||||
" 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"
|
||||
|
@ -1386,8 +1386,10 @@ static int help(int argc, char *argv[], void *userdata) {
|
||||
" --kill-who=WHO Who to send signal to\n"
|
||||
" -s --signal=SIGNAL Which signal to send\n"
|
||||
" -n --lines=INTEGER Number of journal entries to show\n"
|
||||
" -o --output=STRING Change journal output mode (short, short-monotonic,\n"
|
||||
" verbose, export, json, json-pretty, json-sse, cat)\n\n"
|
||||
" -o --output=STRING Change journal output mode (short, short-precise,\n"
|
||||
" short-iso, short-iso-precise, short-full,\n"
|
||||
" short-monotonic, short-unix, verbose, export,\n"
|
||||
" json, json-pretty, json-sse, cat)\n"
|
||||
"Session Commands:\n"
|
||||
" list-sessions List sessions\n"
|
||||
" session-status [ID...] Show session status\n"
|
||||
|
@ -2694,9 +2694,10 @@ static int help(int argc, char *argv[], void *userdata) {
|
||||
" --mkdir Create directory before bind mounting, if missing\n"
|
||||
" -n --lines=INTEGER Number of journal entries to show\n"
|
||||
" --max-addresses=INTEGER Number of internet addresses to show at most\n"
|
||||
" -o --output=STRING Change journal output mode (short,\n"
|
||||
" short-monotonic, verbose, export, json,\n"
|
||||
" json-pretty, json-sse, cat)\n"
|
||||
" -o --output=STRING Change journal output mode (short, short-precise,\n"
|
||||
" short-iso, short-iso-precise, short-full,\n"
|
||||
" short-monotonic, short-unix, verbose, export,\n"
|
||||
" json, json-pretty, json-sse, cat)\n"
|
||||
" --verify=MODE Verification mode for downloaded images (no,\n"
|
||||
" checksum, signature)\n"
|
||||
" --force Download image even if already exists\n\n"
|
||||
|
@ -264,6 +264,8 @@ static int output_timestamp_realtime(FILE *f, sd_journal *j, OutputMode mode, Ou
|
||||
}
|
||||
|
||||
} else {
|
||||
char usec[7];
|
||||
|
||||
gettime_r = (flags & OUTPUT_UTC) ? gmtime_r : localtime_r;
|
||||
t = (time_t) (x / USEC_PER_SEC);
|
||||
|
||||
@ -275,11 +277,21 @@ static int output_timestamp_realtime(FILE *f, sd_journal *j, OutputMode mode, Ou
|
||||
|
||||
case OUTPUT_SHORT_ISO:
|
||||
if (strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S%z", gettime_r(&t, &tm)) <= 0) {
|
||||
log_error("Failed for format ISO time");
|
||||
log_error("Failed to format ISO time");
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
|
||||
case OUTPUT_SHORT_ISO_PRECISE:
|
||||
/* No usec in strftime, so we leave space and copy over */
|
||||
if (strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S.xxxxxx%z", gettime_r(&t, &tm)) <= 0) {
|
||||
log_error("Failed to format ISO-precise time");
|
||||
return -EINVAL;
|
||||
}
|
||||
xsprintf(usec, "%06"PRI_USEC, x % USEC_PER_SEC);
|
||||
memcpy(buf + 20, usec, 6);
|
||||
break;
|
||||
|
||||
case OUTPUT_SHORT:
|
||||
case OUTPUT_SHORT_PRECISE:
|
||||
|
||||
@ -949,6 +961,7 @@ static int (*output_funcs[_OUTPUT_MODE_MAX])(
|
||||
|
||||
[OUTPUT_SHORT] = output_short,
|
||||
[OUTPUT_SHORT_ISO] = output_short,
|
||||
[OUTPUT_SHORT_ISO_PRECISE] = output_short,
|
||||
[OUTPUT_SHORT_PRECISE] = output_short,
|
||||
[OUTPUT_SHORT_MONOTONIC] = output_short,
|
||||
[OUTPUT_SHORT_UNIX] = output_short,
|
||||
|
@ -24,6 +24,7 @@ static const char *const output_mode_table[_OUTPUT_MODE_MAX] = {
|
||||
[OUTPUT_SHORT] = "short",
|
||||
[OUTPUT_SHORT_FULL] = "short-full",
|
||||
[OUTPUT_SHORT_ISO] = "short-iso",
|
||||
[OUTPUT_SHORT_ISO_PRECISE] = "short-iso-precise",
|
||||
[OUTPUT_SHORT_PRECISE] = "short-precise",
|
||||
[OUTPUT_SHORT_MONOTONIC] = "short-monotonic",
|
||||
[OUTPUT_SHORT_UNIX] = "short-unix",
|
||||
|
@ -25,6 +25,7 @@ typedef enum OutputMode {
|
||||
OUTPUT_SHORT,
|
||||
OUTPUT_SHORT_FULL,
|
||||
OUTPUT_SHORT_ISO,
|
||||
OUTPUT_SHORT_ISO_PRECISE,
|
||||
OUTPUT_SHORT_PRECISE,
|
||||
OUTPUT_SHORT_MONOTONIC,
|
||||
OUTPUT_SHORT_UNIX,
|
||||
|
@ -7001,7 +7001,8 @@ static void systemctl_help(void) {
|
||||
" --root=PATH Enable unit files in the specified root directory\n"
|
||||
" -n --lines=INTEGER Number of journal entries to show\n"
|
||||
" -o --output=STRING Change journal output mode (short, short-precise,\n"
|
||||
" short-iso, short-full, short-monotonic, short-unix,\n"
|
||||
" short-iso, short-iso-precise, short-full,\n"
|
||||
" short-monotonic, short-unix,\n"
|
||||
" verbose, export, json, json-pretty, json-sse, cat)\n"
|
||||
" --firmware-setup Tell the firmware to show the setup menu on next boot\n"
|
||||
" --plain Print unit dependencies as a list instead of a tree\n\n"
|
||||
|
Loading…
Reference in New Issue
Block a user