Skip to content

Commit

Permalink
ref(14): Refactor log with printf in place of echo
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanjerome committed Sep 18, 2023
1 parent 7e1a513 commit 4278547
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/lib/log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ log__log() {
fi

if [ "$LOG_LEVEL" -le "$level" ]; then
echo -e "${color}[${LOG_LEVELS[$level]}] $message${color_off}" | tee -a "${LOG_PATH}/stdout.log" >&2
#echo -e "${color}[${LOG_LEVELS[$level]}] $message${color_off}" | tee -a "${LOG_PATH}/stdout.log" >&2
printf "%b[%s] %s%b\n" "$color" "${LOG_LEVELS[$level]}" "$message" "$color_off" | tee -a "${LOG_PATH}/stdout.log" >&2
fi
}

Expand All @@ -102,9 +103,14 @@ log__banner() {
return 2
fi

echo -e "${color}################################${color_off}" | tee -a "${LOG_PATH}/stdout.log" >&2
echo -e "${color} $message${color_off}" | tee -a "${LOG_PATH}/stdout.log" >&2
echo -e "${color}################################${color_off}" | tee -a "${LOG_PATH}/stdout.log" >&2
#echo -e "${color}################################${color_off}" | tee -a "${LOG_PATH}/stdout.log" >&2
#echo -e "${color} $message${color_off}" | tee -a "${LOG_PATH}/stdout.log" >&2
#echo -e "${color}################################${color_off}" | tee -a "${LOG_PATH}/stdout.log" >&2

printf "%b################################%b\n" "$color" "$color_off" | tee -a "${LOG_PATH}/stdout.log" >&2
printf "%b %s%b\n" "$color" "$message" "$color_off" | tee -a "${LOG_PATH}/stdout.log" >&2
printf "%b################################%b\n" "$color" "$color_off" | tee -a "${LOG_PATH}/stdout.log" >&2

}


Expand Down

0 comments on commit 4278547

Please sign in to comment.