Skip to content

Commit

Permalink
Slightly improve preamble: logfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Olf0 authored Apr 2, 2023
1 parent b42ddce commit 22e2b97
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions bin/sailfishos-chum-gui-installer
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,14 @@ logfile="$2"
umask 113
[ "$PWD" = / ] || cd / # Set PWD to /, if not already

# Prefix first output with one plus two linebreaks, if logfile size > 0
linebreaks=''
# Prefix first output with a linebreak, dashes and another linebreak, if logfile size > 0
if [ -s "$logfile" ]
then linebreaks='\n-----------------------------\n\n'
then printf '\n%s\n\n' "-----------------------------"
fi

# Write first entry to logfile:
logentry="[Info] PID $mypid is logging to $logfile"
if printf "${linebreaks}%s\n" "$(date -Iseconds) $logentry"
logentry="[Info] PID $mypid is logging to $logfile on"
if printf '%s %s\n' "$logentry" "$(date -Iseconds)"
then systemd-cat -t "$called" -p 6 printf '%s\n' "$logentry"
else systemd-cat -t "$called" -p 4 printf '%s\n' "[Warning] PID $mypid failed to write to $logfile"
fi
Expand Down

0 comments on commit 22e2b97

Please sign in to comment.