Skip to content

Commit

Permalink
Strip escape codes out of logs
Browse files Browse the repository at this point in the history
Colour and bold formatting gets put in the log files too which can make reading them difficult, this commit attempts to strip them out
  • Loading branch information
tomjn authored Oct 20, 2024
1 parent 2e2c436 commit 5b274eb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions provision/provision-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ function log_to_file() {
exec 2>&7
# pipe to file
if [[ "${1}" == "provisioner-main" ]]; then
exec > >( tee -a "${logfile}" ) # main provisioner outputs everything
exec > >( tee -a "${logfile}" | sed -r "s/\x1B\[[0-9;]*[mK]//g" ) # main provisioner outputs everything
else
exec > >( tee -a "${logfile}" >/dev/null ) # others, only stderr
exec > >( tee -a "${logfile}" | sed -r "s/\x1B\[[0-9;]*[mK]//g" >/dev/null ) # others, only stderr
fi
exec 2> >( tee -a "${logfile}" >&2 )
exec 2> >( tee -a "${logfile}" | sed -r "s/\x1B\[[0-9;]*[mK]//g" >&2 )
VVV_CURRENT_LOG_FILE="${logfile}"
}
export -f log_to_file
Expand Down

0 comments on commit 5b274eb

Please sign in to comment.