Skip to content

Commit

Permalink
adding logging to feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Campbell committed Jun 11, 2024
1 parent 164de5d commit f4919ef
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .devcontainer/features/k3s-on-host/updateContent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,20 @@ function run_a_script() {
fi
}

############################################################
# Pretty writes a parameter to the log file
############################################################
function write_parameter_to_log() {
local parameter=$1
local parameter_value=${!1}
max_key_length=40

parameter_value="${parameter_value// /}" # remove blank spaces from value
padding=$((max_key_length - ${#parameter}))
spaces=$(printf "%-${padding}s" " ")
info_log "${parameter}:${spaces}${parameter_value}"
}

############################################################
# Reset the log file by renaming it with a timestamp and
# creating a new empty log file
Expand Down Expand Up @@ -475,6 +489,17 @@ UPDATE_END"
function main() {
[[ "${CLUSTER_ENABLED}" == "false" ]] && return

info_log "START: ${SCRIPT_NAME}"
info_log "------------------------------------------"
info_log "Config:"
write_parameter_to_log PWD

current_tty=$(tty)

write_parameter_to_log current_tty



reset_log
host_interface_setup

Expand Down

0 comments on commit f4919ef

Please sign in to comment.