Skip to content

Commit 0dffda9

Browse files
committed
feat: improve logging for email-unit-invocation-logs
1 parent 66d37b8 commit 0dffda9

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

utils/email-unit-invocation-logs@.service

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@ SyslogIdentifier=logmailer
1414
SyslogLevel=err
1515
Type=oneshot
1616
ExecStart=/bin/sh -euc '\
17-
inv=$(systemctl ${SD_ARGS} show -P InvocationID %i | grep ^.) \n\
17+
sd_ver=$(systemctl --version | awk \'NR == 1 { print $2 }\') \n\
18+
filt= \n\
19+
if [ "$$sd_ver" -ge 257 ]; then \n\
20+
filt=$$filt" --unit %i --invocation=0" \n\
21+
else \n\
22+
inv=$(systemctl ${SD_ARGS} show -P InvocationID %i | grep ^.) \n\
23+
filt=$$filt" INVOCATION_ID=$$inv + USER_INVOCATION_ID=$$inv + _SYSTEMD_INVOCATION_ID=$$inv" \n\
24+
fi \n\
25+
[ "$$sd_ver" -ge 256 ] && echo %i | grep -Evq \'^podman([.@]|$)\' && \n\
26+
filt=$$filt" --exclude-identifier=podman" \n\
1827
STATE=$(systemctl ${SD_ARGS} is-active %i || true) \n\
19-
LOGS=$(journalctl ${SD_ARGS} --all --no-hostname \
20-
INVOCATION_ID=$$inv \
21-
+ USER_INVOCATION_ID=$$inv \
22-
+ _SYSTEMD_INVOCATION_ID=$$inv) \n\
28+
LOGS=$(journalctl ${SD_ARGS} --all --no-hostname $$filt) \n\
2329
sendmail -i "$1" <<_TPL_EOF\nSubject: ${EMAIL_SUBJ}\n\n${EMAIL_TPL}\n_TPL_EOF\n\
2430
' -- $EMAIL_TGTS

0 commit comments

Comments
 (0)