The log_write() function passes the log message through `date' to
prepend the timestamp to it. This causes problems when the message
contains format placeholders that are interpreted by date.
This commit changes the log_write() function not to pass the log
message and prefix through date.
if (( $# > 2 )); then
for line in "${@:3}"; do
- local msg
+ local timestamp
- if ! msg=$(date +"%F %T %z $$ $prefix $line"); then
+ if ! timestamp=$(date +"%F %T %z"); then
echo "Could not get timestamp" 1>&2
return 1
fi
- if ! echo "$msg" >> "$__log_file"; then
+ if ! echo "$timestamp $$ $prefix $line" >> "$__log_file"; then
echo "Could not write to $__log_file" 1>&2
fi
- echo "$msg" 1>&2
+ echo "$timestamp $$ $prefix $line" 1>&2
done
else
while read -r line; do