Label on each log line (again)

This commit is contained in:
Søren Theilgaard
2022-01-14 10:14:29 +01:00
parent fee9394751
commit e4a5f47272

View File

@@ -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