2021-10-12 17:36:09 +00:00
|
|
|
{ jq, stockholm, systemd, writeDashBin }:
|
2017-12-21 00:24:11 +00:00
|
|
|
|
|
|
|
let
|
2021-10-12 17:36:09 +00:00
|
|
|
lib = stockholm.lib;
|
2017-12-21 00:24:11 +00:00
|
|
|
user = "exim"; # TODO make this configurable
|
|
|
|
in
|
|
|
|
|
|
|
|
# TODO execute eximlog only if journalctl doesn't fail
|
|
|
|
# bash's set -o pipefail isn't enough
|
|
|
|
|
|
|
|
writeDashBin "eximlog" ''
|
|
|
|
${systemd}/bin/journalctl \
|
|
|
|
-u ${lib.shell.escape user} \
|
|
|
|
-o short-unix \
|
|
|
|
"$@" \
|
|
|
|
|
|
|
|
|
${jq}/bin/jq -Rr '
|
|
|
|
# Only select lines that start with a timestamp
|
|
|
|
select(test("^[0-9]")) |
|
|
|
|
|
|
|
|
split(" ") |
|
|
|
|
(.[0] | tonumber) as $time |
|
|
|
|
(.[3:] | join(" ")) as $message |
|
|
|
|
|
|
|
|
"\($time | strftime("%Y-%m-%d %H:%M:%S %z")) \($message)"
|
|
|
|
|
|
|
|
'
|
|
|
|
''
|