From e4a5f47272bfdb57019ea4996a06f8f2940a70ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Fri, 14 Jan 2022 10:14:29 +0100 Subject: [PATCH] Label on each log line (again) --- fragments/functions.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fragments/functions.sh b/fragments/functions.sh index cb20292..3c6b17a 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -114,7 +114,7 @@ printlog(){ # Once we finally stop getting duplicate logs output the number of times we got a duplicate. if [[ $logrepeat -gt 1 ]];then - echo "$timestamp" : "${log_priority} : Last Log repeated ${logrepeat} times" | tee -a $log_location + echo "$timestamp" : "${log_priority} : $label : Last Log repeated ${logrepeat} times" | tee -a $log_location if [[ ! -z $datadogAPI ]]; then 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 : $APPLICATION : $VERSION : $SESSION : Last Log repeated ${logrepeat} times" > /dev/null @@ -134,9 +134,9 @@ printlog(){ if [[ ${levels[$log_priority]} -ge ${levels[$LOGGING]} ]]; then while IFS= read -r logmessage; do if [[ "$(whoami)" == "root" ]]; then - echo "$timestamp" : "${log_priority} : ${logmessage}" | tee -a $log_location + echo "$timestamp" : "${log_priority} : $label : ${logmessage}" | tee -a $log_location else - echo "$timestamp" : "${log_priority} : ${logmessage}" + echo "$timestamp" : "${log_priority} : $label : ${logmessage}" fi done <<< "$log_message" fi