diff options
author | jeschli <jeschli@gmail.com> | 2018-01-05 21:14:15 +0100 |
---|---|---|
committer | jeschli <jeschli@gmail.com> | 2018-01-05 21:14:15 +0100 |
commit | 183b001e1aca601e420ef07ec4944a15c13a8d2c (patch) | |
tree | 9d34f79c2ee7cb073a39ab44ef2795055a42d067 /krebs/5pkgs/simple/eximlog.nix | |
parent | ea85e788ae2a6ca24ccb997372542f7f2a104080 (diff) | |
parent | e083b18e34519f30bba79dfd894c3b828fd13da7 (diff) |
Merge branch 'master' of prism.r:stockholm
Diffstat (limited to 'krebs/5pkgs/simple/eximlog.nix')
-rw-r--r-- | krebs/5pkgs/simple/eximlog.nix | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/krebs/5pkgs/simple/eximlog.nix b/krebs/5pkgs/simple/eximlog.nix new file mode 100644 index 000000000..2d64e13e9 --- /dev/null +++ b/krebs/5pkgs/simple/eximlog.nix @@ -0,0 +1,28 @@ +{ jq, systemd, writeDashBin }: + +let + lib = import <stockholm/lib>; + 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)" + + ' +'' |