From ee9861c0f52dfcef839ed230cc0af07f18aaecfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Fri, 4 Feb 2022 09:02:56 +0100 Subject: [PATCH] Extra space to align log output --- fragments/functions.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fragments/functions.sh b/fragments/functions.sh index 6958a13..c0b4c91 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -97,14 +97,21 @@ printlog(){ curl -s -X POST https://http-intake.logs.datadoghq.com/v1/input -H "Content-Type: text/plain" -H "DD-API-KEY: $datadogAPI" -d "${log_priority} : $mdmURL : Installomator-${label} : ${VERSIONDATE//-/} : $SESSION : ${logmessage}" > /dev/null done <<< "$log_message" fi - + + # Extra spaces + space_char="" + if [[ ${#log_priority} -eq 3 ]]; then + space_char=" " + elif [[ ${#log_priority} -eq 4 ]]; then + space_char=" " + fi # If our logging level is greaterthan or equal to our set level then output locally. if [[ ${levels[$log_priority]} -ge ${levels[$LOGGING]} ]]; then while IFS= read -r logmessage; do if [[ "$(whoami)" == "root" ]]; then - echo "$timestamp" : "${log_priority} : $label : ${logmessage}" | tee -a $log_location + echo "$timestamp" : "${log_priority}${space_char} : $label : ${logmessage}" | tee -a $log_location else - echo "$timestamp" : "${log_priority} : $label : ${logmessage}" + echo "$timestamp" : "${log_priority}${space_char} : $label : ${logmessage}" fi done <<< "$log_message" fi