feat: Update log()

This commit is contained in:
ge 2022-05-19 08:53:14 +03:00
parent 63af638018
commit e60a644968

View File

@ -26,9 +26,6 @@ log() {
local message
local print
local log_file
log_file="$__log_file"
# Read message from STDIN if args not passed.
[[ ! -t 0 ]] || [[ "$#" == 0 ]] && message="$(cat <&0)"
@ -48,7 +45,7 @@ log() {
while read -r line; do
if [[ "$line" ]]; then
printf '[%s] [%s] %s\n' "$(date +"$log_date_fmt")" "$0" "$line" >> "$log_file"
printf '[%s] %s\n' "$(date +"$log_date_fmt")" "$line" >> "$__log_file"
fi
done <<< "$(sed -r 's/\x1B\[(([0-9]+)(;[0-9]+)*)?[m,K,H,f,J]//g' <<< "$message")"
}