armbian-next: introduce `ARMBIAN_LOGS_TO_JOURNAL` and `ARMBIAN_LOGS_JOURNAL_IDENTIFIER` (logs `display_alert` to journald)

This commit is contained in:
Ricardo Pardini 2022-08-23 13:33:41 +02:00
parent 19938837b5
commit 7b47e79780
No known key found for this signature in database
GPG Key ID: 3D38CA12A66C5D02
1 changed files with 5 additions and 0 deletions

View File

@ -211,6 +211,11 @@ function display_alert() {
;;
esac
# Log to journald, if asked to.
if [[ "${ARMBIAN_LOGS_TO_JOURNAL}" == "yes" ]]; then
echo -e "${level}: ${1} [ ${2} ]" | sed 's/\x1b\[[0-9;]*m//g' | systemd-cat --identifier="${ARMBIAN_LOGS_JOURNAL_IDENTIFIER:-armbian}"
fi
# Now, log to file. This will be colorized later by ccze and such, so remove any colors it might already have.
# See also the stuff done in runners.sh for logging exact command lines and runtimes.
# the "echo" runs in a subshell due to the "sed" pipe (! important !), so we store BASHPID (current subshell) outside the scope