feat: Update log()
This commit is contained in:
parent
63af638018
commit
e60a644968
@ -26,9 +26,6 @@ log() {
|
|||||||
|
|
||||||
local message
|
local message
|
||||||
local print
|
local print
|
||||||
local log_file
|
|
||||||
|
|
||||||
log_file="$__log_file"
|
|
||||||
|
|
||||||
# Read message from STDIN if args not passed.
|
# Read message from STDIN if args not passed.
|
||||||
[[ ! -t 0 ]] || [[ "$#" == 0 ]] && message="$(cat <&0)"
|
[[ ! -t 0 ]] || [[ "$#" == 0 ]] && message="$(cat <&0)"
|
||||||
@ -48,7 +45,7 @@ log() {
|
|||||||
|
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
if [[ "$line" ]]; then
|
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
|
fi
|
||||||
done <<< "$(sed -r 's/\x1B\[(([0-9]+)(;[0-9]+)*)?[m,K,H,f,J]//g' <<< "$message")"
|
done <<< "$(sed -r 's/\x1B\[(([0-9]+)(;[0-9]+)*)?[m,K,H,f,J]//g' <<< "$message")"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user