fixed logging output

This commit is contained in:
pyr0ball 2023-01-11 10:20:52 -08:00
parent d388db110f
commit 83c236c74c

View file

@ -2,7 +2,7 @@
# pyr0ball script functions library
# Initial Vars
functionsrev=1.1.1
functionsrev=1.1.2
scriptname="${0##*/}"
rundir="${0%/*}"
rundir_absolute=$(cd `dirname $0` && pwd)
@ -495,24 +495,27 @@ boxborder(){
}
success(){
_line="$@"
echo -e "\n"
boxborder " ${scriptname} ${grn}SUCCESS${dfl}$@"
boxborder "${scriptname} ${grn}SUCCESS${dfl} ${_line}"
exit 0
}
warn(){
echo -e "\n"
ec=$?
_line="$@"
echo -e "\n"
boxtop
boxline "${lrd}WARNING${lyl}[${ong}code=${red}$ec${lyl}]: $@${dfl}"
boxline "${lrd}WARNING${lyl}[${ong}code=${red}$ec${lyl}]: ${_line}${dfl}"
boxbottom
}
fail(){
ec=$?
_line="$@"
echo -e "\n"
boxtop
boxline "${lrd}FAILED${lyl}[${ong}code=${red}$ec${lyl}]: $@${dfl}"
boxline "${lrd}FAILED${lyl}[${ong}code=${red}$ec${lyl}]: ${_line}${dfl}"
boxbottom
exit $ec
}
@ -536,7 +539,8 @@ logger(){
#$@ 2>&1 | tee >(ts "[$scriptname][%d-%m-%y %H_%M_%S]" > $logfile) # This version of prepend requires the 'ts' utility from 'moreutils' package
$@ 2>&1 | tee >(
while IFS= read -r line; do
printf '[%s] %s\n' "${scriptname}][${pretty_date}" "$line"
_line=$(echo $line | sed "s,\x1B\[[0-9;]*[mK],,g" | tr -dc '[:print:]')
printf '[%s] %s\n' "${scriptname}][${prettyDate}" "$_line"
done >> $logfile
)
}