mirror of
https://github.com/mtan93/Installomator.git
synced 2026-04-03 06:13:12 +01:00
Local logging improvements
Improved first lines of logs to be required and show `VERSION` and `VERSIONDATE` on separate lines. Logging sent to Datadog will have `VERSION` on each line.
This commit is contained in:
@@ -43,12 +43,14 @@ if [[ $label == "version" ]]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printlog "################## Start Installomator v. $VERSION"
|
printlog "################## Start Installomator" REQ
|
||||||
printlog "################## $label"
|
printlog "################## Version: $VERSION" REQ
|
||||||
|
printlog "################## Date: $VERSIONDATE" REQ
|
||||||
|
printlog "################## $label" REQ
|
||||||
|
|
||||||
# Check for DEBUG mode
|
# Check for DEBUG mode
|
||||||
if [[ $DEBUG -gt 0 ]]; then
|
if [[ $DEBUG -gt 0 ]]; then
|
||||||
printlog "DEBUG mode $DEBUG enabled."
|
printlog "DEBUG mode $DEBUG enabled." DEBUG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# How we get version number from app
|
# How we get version number from app
|
||||||
|
|||||||
@@ -112,10 +112,10 @@ printlog(){
|
|||||||
|
|
||||||
# Once we finally stop getting duplicate logs output the number of times we got a duplicate.
|
# Once we finally stop getting duplicate logs output the number of times we got a duplicate.
|
||||||
if [[ $logrepeat -gt 1 ]];then
|
if [[ $logrepeat -gt 1 ]];then
|
||||||
echo "$timestamp" : "${log_priority} : ${VERSIONDATE//-/} : Last Log repeated ${logrepeat} times" | tee -a $log_location
|
echo "$timestamp" : "${log_priority} : Last Log repeated ${logrepeat} times" | tee -a $log_location
|
||||||
|
|
||||||
if [[ ! -z $datadogAPI ]]; then
|
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 : $VERSIONDATE : $SESSION : Last Log repeated ${logrepeat} times" > /dev/null
|
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
|
||||||
fi
|
fi
|
||||||
logrepeat=0
|
logrepeat=0
|
||||||
fi
|
fi
|
||||||
@@ -132,18 +132,12 @@ printlog(){
|
|||||||
if [[ ${levels[$log_priority]} -ge ${levels[$LOGGING]} ]]; then
|
if [[ ${levels[$log_priority]} -ge ${levels[$LOGGING]} ]]; then
|
||||||
while IFS= read -r logmessage; do
|
while IFS= read -r logmessage; do
|
||||||
if [[ "$(whoami)" == "root" ]]; then
|
if [[ "$(whoami)" == "root" ]]; then
|
||||||
echo "$timestamp" : "${log_priority} : ${VERSIONDATE//-/} : ${logmessage}" | tee -a $log_location
|
echo "$timestamp" : "${log_priority} : ${logmessage}" | tee -a $log_location
|
||||||
else
|
else
|
||||||
echo "$timestamp" : "${log_priority} : ${VERSIONDATE//-/} : ${logmessage}"
|
echo "$timestamp" : "${log_priority} : ${logmessage}"
|
||||||
fi
|
fi
|
||||||
done <<< "$log_message"
|
done <<< "$log_message"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if [[ "$(whoami)" == "root" ]]; then
|
|
||||||
# echo "$timestamp" "$label" "$1" | tee -a $log_location
|
|
||||||
# else
|
|
||||||
# echo "$timestamp" "$label" "$1"
|
|
||||||
# fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Used to remove dupplicate lines in large log output, for example from msupdate command
|
# Used to remove dupplicate lines in large log output, for example from msupdate command
|
||||||
|
|||||||
Reference in New Issue
Block a user