journalctl: add --output-fields= (#7181)
This option allows restricting the shown fields in the output modes that would normally show all fields. It allows clients that are only interested in a subset of the fields to access those more efficiently. Also, it makes the resulting size of the output more predictable. It has no effect on the various `short` output modes, because those already only show a subset of the fields.
This commit is contained in:
committed by
Yu Watanabe
parent
a8caf8b251
commit
cc25a67e2a
@@ -51,6 +51,18 @@ journalctl --sync
|
||||
journalctl -b -o cat -t "$ID" >/output
|
||||
cmp /expected /output
|
||||
|
||||
# --output-fields restricts output
|
||||
ID=$(journalctl --new-id128 | sed -n 2p)
|
||||
printf $'foo' | systemd-cat -t "$ID" --level-prefix false
|
||||
journalctl --sync
|
||||
journalctl -b -o export --output-fields=MESSAGE,FOO --output-fields=PRIORITY,MESSAGE -t "$ID" >/output
|
||||
[[ `grep -c . /output` -eq 6 ]]
|
||||
grep -q '^__CURSOR=' /output
|
||||
grep -q '^MESSAGE=foo$' /output
|
||||
grep -q '^PRIORITY=6$' /output
|
||||
! grep -q '^FOO=' /output
|
||||
! grep -q '^SYSLOG_FACILITY=' /output
|
||||
|
||||
# Don't lose streams on restart
|
||||
systemctl start forever-print-hola
|
||||
sleep 3
|
||||
|
||||
Reference in New Issue
Block a user