diff --git a/.vscode/launch.json b/.vscode/launch.json index ebd1b7a0..38de8bdd 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,7 +9,8 @@ "request": "launch", "name": "Launch Program", "program": "${workspaceFolder}/src/butler.js", - "runtimeVersion": "20", + // "runtimeVersion": "20", + "runtimeVersion": "18", "cwd": "${workspaceFolder}/src", "env": { "NODE_CONFIG_DIR": "${workspaceFolder}/src/config", diff --git a/src/config/email_templates/aborted-reload-qseow.handlebars b/src/config/email_templates/aborted-reload-qseow.handlebars index a043c6e8..e34eab66 100644 --- a/src/config/email_templates/aborted-reload-qseow.handlebars +++ b/src/config/email_templates/aborted-reload-qseow.handlebars @@ -186,7 +186,8 @@ - The script log contains {{scriptLogSize}} rows in total. Here are the first ones: + The script log contains {{scriptLogSizeRows}} rows in total, with {{scriptLogSizeCharacters}} characters in them.
+ Here are the first {{scriptLogHeadCount}} rows: diff --git a/src/config/email_templates/failed-reload-qscloud.handlebars b/src/config/email_templates/failed-reload-qscloud.handlebars index d80a2e5b..3035a261 100644 --- a/src/config/email_templates/failed-reload-qscloud.handlebars +++ b/src/config/email_templates/failed-reload-qscloud.handlebars @@ -152,7 +152,8 @@ - The script log contains {{scriptLogSize}} rows in total. Here are the first ones: + The script log contains {{scriptLogSizeRows}} rows in total, with {{scriptLogSizeCharacters}} characters in them.
+ Here are the first {{scriptLogHeadCount}} rows: diff --git a/src/config/email_templates/failed-reload-qseow.handlebars b/src/config/email_templates/failed-reload-qseow.handlebars index 9aa4098e..6e502c29 100644 --- a/src/config/email_templates/failed-reload-qseow.handlebars +++ b/src/config/email_templates/failed-reload-qseow.handlebars @@ -186,7 +186,8 @@ - The script log contains {{scriptLogSize}} rows in total. Here are the first ones: + The script log contains {{scriptLogSizeRows}} rows in total, with {{scriptLogSizeCharacters}} characters in them.
+ Here are the first {{scriptLogHeadCount}} rows: diff --git a/src/config/slack_templates/failed-reload-qscloud.handlebars b/src/config/slack_templates/failed-reload-qscloud.handlebars index 4964c7e4..9c4158a6 100644 --- a/src/config/slack_templates/failed-reload-qscloud.handlebars +++ b/src/config/slack_templates/failed-reload-qscloud.handlebars @@ -157,7 +157,7 @@ "type": "section", "text": { "type": "mrkdwn", - "text": "The script log contains {{scriptLogSize}} rows in total. Here are the first ones:" + "text": "The script log contains {{scriptLogSizeRows}} rows in total, with {{scriptLogSizeCharacters}} characters in them. Here are the first {{scriptLogHeadCount}} rows:" } }, { diff --git a/src/config/slack_templates/failed-reload-qseow.handlebars b/src/config/slack_templates/failed-reload-qseow.handlebars index 48d9fd08..482012c6 100644 --- a/src/config/slack_templates/failed-reload-qseow.handlebars +++ b/src/config/slack_templates/failed-reload-qseow.handlebars @@ -149,7 +149,7 @@ "type": "section", "text": { "type": "mrkdwn", - "text": "The script log contains {{scriptLogSize}} characters in total. Here are the first lines:" + "text": "The script log contains {{scriptLogSizeRows}} rows in total, with {{scriptLogSizeCharacters}} characters in them. Here are the first {{scriptLogHeadCount}} rows:" } }, { @@ -163,7 +163,7 @@ "type": "section", "text": { "type": "mrkdwn", - "text": "Here are the last few lines:" + "text": "Here are the last {{scriptLogTailCount}} rows:" } }, { diff --git a/src/config/teams_templates/failed-reload-qscloud.handlebars b/src/config/teams_templates/failed-reload-qscloud.handlebars index 16859e8b..53bd1263 100644 --- a/src/config/teams_templates/failed-reload-qscloud.handlebars +++ b/src/config/teams_templates/failed-reload-qscloud.handlebars @@ -194,6 +194,31 @@ } ] }, + { + "type": "Container", + "spacing": "extraLarge", + "style": "emphasis", + "items": [ + { + "type": "TextBlock", + "size": "large", + "weight": "bolder", + "text": "Beginning of script log", + "style": "heading" + }, + { + "type": "TextBlock", + "size": "small", + "weight": "normal", + "text": "The script log contains {{scriptLogSizeRows}} rows in total, with {{scriptLogSizeCharacters}} characters in them. Here are the first {{scriptLogHeadCount}} rows:", + "style": "heading" + }, + { + "type": "CodeBlock", + "codeSnippet": "{{scriptLogHead}}" + } + ] + }, { "type": "Container", "spacing": "extraLarge", @@ -210,7 +235,7 @@ "type": "TextBlock", "size": "small", "weight": "normal", - "text": "Last {{scriptLogTailCount}} rows shown. The script log contains {{scriptLogSize}} rows in total.", + "text": "Here are the last {{scriptLogTailCount}} rows:", "style": "heading" }, { diff --git a/src/config/teams_templates/failed-reload-qseow.handlebars b/src/config/teams_templates/failed-reload-qseow.handlebars index 2ff1912d..fdc06d46 100644 --- a/src/config/teams_templates/failed-reload-qseow.handlebars +++ b/src/config/teams_templates/failed-reload-qseow.handlebars @@ -190,6 +190,31 @@ } ] }, + { + "type": "Container", + "spacing": "extraLarge", + "style": "emphasis", + "items": [ + { + "type": "TextBlock", + "size": "large", + "weight": "bolder", + "text": "Beginning of script log", + "style": "heading" + }, + { + "type": "TextBlock", + "size": "small", + "weight": "normal", + "text": "The script log contains {{scriptLogSizeRows}} rows in total, with {{scriptLogSizeCharacters}} characters in them. Here are the first {{scriptLogHeadCount}} rows:", + "style": "heading" + }, + { + "type": "CodeBlock", + "codeSnippet": "{{scriptLogHead}}" + } + ] + }, { "type": "Container", "spacing": "extraLarge", @@ -206,7 +231,7 @@ "type": "TextBlock", "size": "small", "weight": "normal", - "text": "Last {{scriptLogTailCount}} rows shown. The script log contains {{scriptLogSize}} rows in total.", + "text": "Here are the last {{scriptLogTailCount}} rows:", "style": "heading" }, { diff --git a/src/lib/qscloud/email_notification_qscloud.js b/src/lib/qscloud/email_notification_qscloud.js index f94e9762..007e6621 100644 --- a/src/lib/qscloud/email_notification_qscloud.js +++ b/src/lib/qscloud/email_notification_qscloud.js @@ -6,6 +6,7 @@ import { getQlikSenseCloudUserInfo } from './api/user.js'; import { getQlikSenseCloudAppInfo } from './api/app.js'; import { getQlikSenseCloudUrls } from './util.js'; import { sendEmail, isSmtpConfigOk } from '../qseow/smtp.js'; +import { getQlikSenseCloudAppReloadScriptLogHead, getQlikSenseCloudAppReloadScriptLogTail } from './api/appreloadinfo.js'; let rateLimiterMemoryFailedReloads; let emailConfig; @@ -232,16 +233,17 @@ export async function sendQlikSenseCloudAppReloadFailureNotificationEmail(reload // Get length of script log (row count) scriptLogData.scriptLogSizeRows = reloadParams.scriptLog.scriptLogFull.length; - // Get the first and last n lines of the script log - scriptLogData.scriptLogHead = reloadParams.scriptLog.scriptLogFull.slice(0, scriptLogData.scriptLogHeadCount).join('\r\n'); + // Get length of entire script log (character count) + scriptLogData.scriptLogSizeCharacters = reloadParams.scriptLog.scriptLogFull.join('').length; - scriptLogData.scriptLogTail = reloadParams.scriptLog.scriptLogFull - .slice(Math.max(reloadParams.scriptLog.scriptLogFull.length - scriptLogData.scriptLogTailCount, 0)) - .join('\r\n'); + // Get the first and last rows of the script log + scriptLogData.scriptLogHead = getQlikSenseCloudAppReloadScriptLogHead(reloadParams.scriptLog.scriptLogFull, scriptLogData.scriptLogHeadCount); + scriptLogData.scriptLogTail = getQlikSenseCloudAppReloadScriptLogTail(reloadParams.scriptLog.scriptLogFull, scriptLogData.scriptLogTailCount); } else { scriptLogData.scriptLogHead = ''; scriptLogData.scriptLogTail = ''; scriptLogData.scriptLogSizeRows = 0; + scriptLogData.scriptLogSizeCharacters = 0; } globals.logger.debug(`EMAIL ALERT - QS CLOUD APP RELOAD FAILED: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`); @@ -309,6 +311,7 @@ export async function sendQlikSenseCloudAppReloadFailureNotificationEmail(reload executionStatusText: reloadParams.reloadInfo.status, scriptLogSize: scriptLogData.scriptLogSizeRows.toLocaleString(), scriptLogSizeRows: scriptLogData.scriptLogSizeRows.toLocaleString(), + scriptLogSizeCharacters: scriptLogData.scriptLogSizeCharacters.toLocaleString(), scriptLogHead: scriptLogData.scriptLogHead, scriptLogTail: scriptLogData.scriptLogTail, scriptLogTailCount: scriptLogData.scriptLogTailCount, diff --git a/src/lib/qscloud/mqtt_event_app_reload_finished.js b/src/lib/qscloud/mqtt_event_app_reload_finished.js index dc58a379..522c62b7 100644 --- a/src/lib/qscloud/mqtt_event_app_reload_finished.js +++ b/src/lib/qscloud/mqtt_event_app_reload_finished.js @@ -5,8 +5,6 @@ import globals from '../../globals.js'; import { getQlikSenseCloudAppReloadScriptLog, getQlikSenseCloudAppReloadInfo, - getQlikSenseCloudAppReloadScriptLogHead, - getQlikSenseCloudAppReloadScriptLogTail, } from './api/appreloadinfo.js'; import { getQlikSenseCloudAppInfo, getQlikSenseCloudAppMetadata, getQlikSenseCloudAppItems } from './api/app.js'; import { sendQlikSenseCloudAppReloadFailureNotificationTeams } from './msteams_notification_qscloud.js'; @@ -222,21 +220,8 @@ export async function handleQlikSenseCloudAppReloadFinished(message) { if ( globals.config.get( 'Butler.qlikSenseCloud.event.mqtt.tenant.alert.teamsNotification.reloadAppFailure.basicContentOnly', - ) === false + ) === true ) { - const headLineCount = globals.config.get( - 'Butler.qlikSenseCloud.event.mqtt.tenant.alert.teamsNotification.reloadAppFailure.headScriptLogLines', - ); - - const tailLineCount = globals.config.get( - 'Butler.qlikSenseCloud.event.mqtt.tenant.alert.teamsNotification.reloadAppFailure.tailScriptLogLines', - ); - - scriptLog.scriptLogHeadCount = headLineCount; - scriptLog.scriptLogTailCount = tailLineCount; - scriptLog.scriptLogHead = getQlikSenseCloudAppReloadScriptLogHead(scriptLog.scriptLogFull, headLineCount); - scriptLog.scriptLogTail = getQlikSenseCloudAppReloadScriptLogTail(scriptLog.scriptLogFull, tailLineCount); - } else { // Use the basic info provided in the event/MQTT message scriptLog = {}; reloadInfo.appId = appId; @@ -294,21 +279,8 @@ export async function handleQlikSenseCloudAppReloadFinished(message) { if ( globals.config.get( 'Butler.qlikSenseCloud.event.mqtt.tenant.alert.slackNotification.reloadAppFailure.basicContentOnly', - ) === false + ) === true ) { - const headLineCount = globals.config.get( - 'Butler.qlikSenseCloud.event.mqtt.tenant.alert.slackNotification.reloadAppFailure.headScriptLogLines', - ); - - const tailLineCount = globals.config.get( - 'Butler.qlikSenseCloud.event.mqtt.tenant.alert.slackNotification.reloadAppFailure.tailScriptLogLines', - ); - - scriptLog.scriptLogHeadCount = headLineCount; - scriptLog.scriptLogTailCount = tailLineCount; - scriptLog.scriptLogHead = getQlikSenseCloudAppReloadScriptLogHead(scriptLog.scriptLogFull, headLineCount); - scriptLog.scriptLogTail = getQlikSenseCloudAppReloadScriptLogTail(scriptLog.scriptLogFull, tailLineCount); - } else { // Use the basic info provided in the event/MQTT message scriptLog = {}; reloadInfo.appId = appId; @@ -369,19 +341,6 @@ export async function handleQlikSenseCloudAppReloadFinished(message) { // - App metadata // - App items - const headLineCount = globals.config.get( - 'Butler.qlikSenseCloud.event.mqtt.tenant.alert.emailNotification.reloadAppFailure.headScriptLogLines', - ); - - const tailLineCount = globals.config.get( - 'Butler.qlikSenseCloud.event.mqtt.tenant.alert.emailNotification.reloadAppFailure.tailScriptLogLines', - ); - - scriptLog.scriptLogHeadCount = headLineCount; - scriptLog.scriptLogTailCount = tailLineCount; - scriptLog.scriptLogHead = getQlikSenseCloudAppReloadScriptLogHead(scriptLog.scriptLogFull, headLineCount); - scriptLog.scriptLogTail = getQlikSenseCloudAppReloadScriptLogTail(scriptLog.scriptLogFull, tailLineCount); - // Send email notification sendQlikSenseCloudAppReloadFailureNotificationEmail({ tenantId, diff --git a/src/lib/qscloud/msteams_notification_qscloud.js b/src/lib/qscloud/msteams_notification_qscloud.js index 043cc9cc..20d59e26 100644 --- a/src/lib/qscloud/msteams_notification_qscloud.js +++ b/src/lib/qscloud/msteams_notification_qscloud.js @@ -8,6 +8,7 @@ import globals from '../../globals.js'; import { getQlikSenseCloudUserInfo } from './api/user.js'; import { getQlikSenseCloudAppInfo } from './api/app.js'; import { getQlikSenseCloudUrls } from './util.js'; +import { getQlikSenseCloudAppReloadScriptLogHead, getQlikSenseCloudAppReloadScriptLogTail } from './api/appreloadinfo.js'; let rateLimiterMemoryFailedReloads; @@ -212,7 +213,7 @@ export function sendQlikSenseCloudAppReloadFailureNotificationTeams(reloadParams scriptLogTailCount: 0, }; } else { - // Reduce script log lines to only the ones we want to send to Teams + // Reduce full script log to head and tail adapted for Teams scriptLogData.scriptLogHeadCount = globals.config.get( 'Butler.qlikSenseCloud.event.mqtt.tenant.alert.teamsNotification.reloadAppFailure.headScriptLogLines', ); @@ -221,21 +222,22 @@ export function sendQlikSenseCloudAppReloadFailureNotificationTeams(reloadParams ); if (reloadParams.scriptLog?.scriptLogFull?.length > 0) { - scriptLogData.scriptLogHead = reloadParams.scriptLog.scriptLogFull - .slice(0, reloadParams.scriptLog.scriptLogHeadCount) - .join('\r\n'); + // Get length of entire script log (character count) + scriptLogData.scriptLogSizeCharacters = reloadParams.scriptLog.scriptLogFull.join('').length; - scriptLogData.scriptLogTail = reloadParams.scriptLog.scriptLogFull - .slice(Math.max(reloadParams.scriptLog.scriptLogFull.length - reloadParams.scriptLog.scriptLogTailCount, 0)) - .join('\r\n'); + // Get length of script log (row count) + scriptLogData.scriptLogSizeRows = reloadParams.scriptLog.scriptLogFull.length; + + // Get the first and last rows of the script log + scriptLogData.scriptLogHead = getQlikSenseCloudAppReloadScriptLogHead(reloadParams.scriptLog.scriptLogFull, scriptLogData.scriptLogHeadCount); + scriptLogData.scriptLogTail = getQlikSenseCloudAppReloadScriptLogTail(reloadParams.scriptLog.scriptLogFull, scriptLogData.scriptLogTailCount); } else { scriptLogData.scriptLogHead = ''; scriptLogData.scriptLogTail = ''; + scriptLogData.scriptLogSizeRows = 0; + scriptLogData.scriptLogSizeCharacters = 0; } - // Get length of script log (row count) - scriptLogData.scriptLogSizeRows = reloadParams.scriptLog.scriptLogFull.length; - globals.logger.debug( `TEAMS ALERT - QS CLOUD APP RELOAD FAILED: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`, ); @@ -300,6 +302,7 @@ export function sendQlikSenseCloudAppReloadFailureNotificationTeams(reloadParams executionStatusText: reloadParams.reloadInfo.status, scriptLogSize: scriptLogData.scriptLogSizeRows.toLocaleString(), scriptLogSizeRows: scriptLogData.scriptLogSizeRows.toLocaleString(), + scriptLogSizeCharacters: scriptLogData.scriptLogSizeCharacters.toLocaleString(), scriptLogHead: scriptLogData.scriptLogHead .replace(/([\r])/gm, '') .replace(/([\n])/gm, '\\n') diff --git a/src/lib/qscloud/slack_notification_qscloud.js b/src/lib/qscloud/slack_notification_qscloud.js index d7622e7f..da03ed71 100644 --- a/src/lib/qscloud/slack_notification_qscloud.js +++ b/src/lib/qscloud/slack_notification_qscloud.js @@ -7,6 +7,7 @@ import slackSend from '../slack_api.js'; import { getQlikSenseCloudUserInfo } from './api/user.js'; import { getQlikSenseCloudAppInfo } from './api/app.js'; import { getQlikSenseCloudUrls } from './util.js'; +import { getQlikSenseCloudAppReloadScriptLogHead, getQlikSenseCloudAppReloadScriptLogTail } from './api/appreloadinfo.js'; let rateLimiterMemoryFailedReloads; @@ -245,21 +246,20 @@ export function sendQlikSenseCloudAppReloadFailureNotificationSlack(reloadParams ); if (reloadParams.scriptLog?.scriptLogFull?.length > 0) { + // Get length of entire script log (character count) + scriptLogData.scriptLogSizeCharacters = reloadParams.scriptLog.scriptLogFull.join('').length; + // Get length of script log (row count) scriptLogData.scriptLogSizeRows = reloadParams.scriptLog.scriptLogFull.length; - // Get the first and last n lines of the script log - scriptLogData.scriptLogHead = reloadParams.scriptLog.scriptLogFull - .slice(0, reloadParams.scriptLog.scriptLogHeadCount) - .join('\r\n'); - - scriptLogData.scriptLogTail = reloadParams.scriptLog.scriptLogFull - .slice(Math.max(reloadParams.scriptLog.scriptLogFull.length - reloadParams.scriptLog.scriptLogTailCount, 0)) - .join('\r\n'); + // Get the first and last rows of the script log + scriptLogData.scriptLogHead = getQlikSenseCloudAppReloadScriptLogHead(reloadParams.scriptLog.scriptLogFull, scriptLogData.scriptLogHeadCount); + scriptLogData.scriptLogTail = getQlikSenseCloudAppReloadScriptLogTail(reloadParams.scriptLog.scriptLogFull, scriptLogData.scriptLogTailCount); } else { scriptLogData.scriptLogHead = ''; scriptLogData.scriptLogTail = ''; scriptLogData.scriptLogSizeRows = 0; + scriptLogData.scriptLogSizeCharacters = 0; } globals.logger.debug( @@ -326,6 +326,7 @@ export function sendQlikSenseCloudAppReloadFailureNotificationSlack(reloadParams executionStatusText: reloadParams.reloadInfo.status, scriptLogSize: scriptLogData.scriptLogSizeRows.toLocaleString(), scriptLogSizeRows: scriptLogData.scriptLogSizeRows.toLocaleString(), + scriptLogSizeCharacters: scriptLogData.scriptLogSizeCharacters.toLocaleString(), scriptLogHead: scriptLogData.scriptLogHead .replace(/([\r])/gm, '') .replace(/([\n])/gm, '\\n') diff --git a/src/lib/qseow/msteams_notification.js b/src/lib/qseow/msteams_notification.js index d1961465..873c1bc2 100644 --- a/src/lib/qseow/msteams_notification.js +++ b/src/lib/qseow/msteams_notification.js @@ -665,6 +665,8 @@ export function sendReloadTaskAbortedNotificationTeams(reloadParams) { .replace(/([\n])/gm, '\\n') .replace(/([\t])/gm, '\\t'), scriptLogSize: scriptLogData.scriptLogSize, + scriptLogSizeRows: scriptLogData.scriptLogSizeRows, + scriptLogSizeCharacters: scriptLogData.scriptLogSizeCharacters, scriptLogHead: scriptLogData.scriptLogHead .replace(/([\r])/gm, '') .replace(/([\n])/gm, '\\n') diff --git a/src/lib/qseow/scriptlog.js b/src/lib/qseow/scriptlog.js index b2ae1e61..62cad748 100644 --- a/src/lib/qseow/scriptlog.js +++ b/src/lib/qseow/scriptlog.js @@ -59,11 +59,11 @@ export async function getReloadTaskExecutionResults(reloadTaskId) { const qrsInstance = new QrsInteract(configQRS); // Step 1 - globals.logger.debug(`GET SCRIPT LOG 1: reloadTaskId: ${reloadTaskId}`); + globals.logger.debug(`[QSEOW] GET SCRIPT LOG 1: reloadTaskId: ${reloadTaskId}`); const result1 = await qrsInstance.Get(`reloadtask/${reloadTaskId}`); - globals.logger.debug(`GET SCRIPT LOG 1: body: ${JSON.stringify(result1.body)}`); + globals.logger.debug(`[QSEOW] GET SCRIPT LOG 1: body: ${JSON.stringify(result1.body)}`); const taskInfo = { fileReferenceId: result1.body.operational.lastExecutionResult.fileReferenceID, @@ -163,7 +163,7 @@ export async function getReloadTaskExecutionResults(reloadTaskId) { return taskInfo; } catch (err) { - globals.logger.error(`GET SCRIPT LOG: ${err}`); + globals.logger.error(`[QSEOW] GET SCRIPT LOG: ${err}`); return false; } } @@ -194,9 +194,11 @@ export async function getScriptLog(reloadTaskId, headLineCount, tailLineCount) { const qrsInstance = new QrsInteract(configQRS); // Only get script log if there is a valid fileReferenceId - globals.logger.debug(`GET SCRIPT LOG 2: taskInfo.fileReferenceId: ${taskInfo.fileReferenceId}`); + globals.logger.debug(`[QSEOW] GET SCRIPT LOG 2: taskInfo.fileReferenceId: ${taskInfo.fileReferenceId}`); if (taskInfo.fileReferenceId !== '00000000-0000-0000-0000-000000000000') { - globals.logger.debug(`GET SCRIPT LOG 3: reloadtask/${reloadTaskId}/scriptlog?fileReferenceId=${taskInfo.fileReferenceId}`); + globals.logger.debug( + `[QSEOW] GET SCRIPT LOG 3: reloadtask/${reloadTaskId}/scriptlog?fileReferenceId=${taskInfo.fileReferenceId}`, + ); const result2 = await qrsInstance.Get(`reloadtask/${reloadTaskId}/scriptlog?fileReferenceId=${taskInfo.fileReferenceId}`); @@ -227,8 +229,14 @@ export async function getScriptLog(reloadTaskId, headLineCount, tailLineCount) { const result3 = await axios.request(axiosConfig); + // Get complete script log as an array of lines const scriptLogFull = result3.data.split('\r\n'); + // Get total number of rows and characters in script log + const scriptLogSizeCharacters = result3.data.length; + const scriptLogSizeRows = scriptLogFull.length; + + // Get head and tail of script log let scriptLogHead = ''; let scriptLogTail = ''; @@ -240,10 +248,10 @@ export async function getScriptLog(reloadTaskId, headLineCount, tailLineCount) { scriptLogTail = scriptLogFull.slice(Math.max(scriptLogFull.length - tailLineCount, 0)).join('\r\n'); } - globals.logger.debug(`GET SCRIPT LOG: Script log head:\n${scriptLogHead}`); - globals.logger.debug(`GET SCRIPT LOG: Script log tails:\n${scriptLogTail}`); + globals.logger.debug(`[QSEOW] GET SCRIPT LOG: Script log head:\n${scriptLogHead}`); + globals.logger.debug(`[QSEOW] GET SCRIPT LOG: Script log tails:\n${scriptLogTail}`); - globals.logger.verbose('GET SCRIPT LOG: Done getting script log'); + globals.logger.verbose('[QSEOW] GET SCRIPT LOG: Done getting script log'); return { executingNodeName: taskInfo.executingNodeName, @@ -256,6 +264,8 @@ export async function getScriptLog(reloadTaskId, headLineCount, tailLineCount) { executionStatusText: taskInfo.executionStatusText, scriptLogFull, scriptLogSize: taskInfo.scriptLogSize, + scriptLogSizeRows: scriptLogSizeRows, + scriptLogSizeCharacters: scriptLogSizeCharacters, scriptLogHead, scriptLogHeadCount: headLineCount, scriptLogTail, @@ -280,7 +290,7 @@ export async function getScriptLog(reloadTaskId, headLineCount, tailLineCount) { scriptLogTailCount: 0, }; } catch (err) { - globals.logger.error(`GET SCRIPT LOG: ${err}`); + globals.logger.error(`[QSEOW] GET SCRIPT LOG: ${err}`); return false; } } @@ -297,7 +307,7 @@ export async function failedTaskStoreLogOnDisk(reloadParams) { const logDate = reloadParams.logTimeStamp.slice(0, 10); const reloadLogDir = path.resolve(reloadLogDirRoot, logDate); - globals.logger.debug(`SCRIPTLOG STORE: Creating directory for failed task script log: ${reloadLogDir}`); + globals.logger.debug(`[QSEOW] SCRIPTLOG STORE: Creating directory for failed task script log: ${reloadLogDir}`); fs.mkdirSync(reloadLogDir, { recursive: true }); const fileName = path.resolve( @@ -307,11 +317,11 @@ export async function failedTaskStoreLogOnDisk(reloadParams) { }.log`, ); - globals.logger.info(`SCRIPTLOG STORE: Writing failed task script log: ${fileName}`); + globals.logger.info(`[QSEOW] SCRIPTLOG STORE: Writing failed task script log: ${fileName}`); fs.writeFileSync(fileName, scriptLog.scriptLogFull.join('\n')); return true; } catch (err) { - globals.logger.error(`SCRIPTLOG STORE: ${err}`); + globals.logger.error(`[QSEOW] SCRIPTLOG STORE: ${err}`); return false; } } diff --git a/src/lib/qseow/slack_notification.js b/src/lib/qseow/slack_notification.js index 415eff6b..8bfc2d0d 100644 --- a/src/lib/qseow/slack_notification.js +++ b/src/lib/qseow/slack_notification.js @@ -521,6 +521,8 @@ export function sendReloadTaskFailureNotificationSlack(reloadParams) { .replace(/([\n])/gm, '\\n') .replace(/([\t])/gm, '\\t'), scriptLogSize: scriptLogData.scriptLogSize, + scriptLogSizeRows: scriptLogData.scriptLogSizeRows, + scriptLogSizeCharacters: scriptLogData.scriptLogSizeCharacters, scriptLogHead: scriptLogData.scriptLogHead .replace(/([\r])/gm, '') .replace(/([\n])/gm, '\\n') diff --git a/src/lib/qseow/smtp.js b/src/lib/qseow/smtp.js index 3b0e10eb..cad3ae22 100644 --- a/src/lib/qseow/smtp.js +++ b/src/lib/qseow/smtp.js @@ -541,6 +541,8 @@ export async function sendReloadTaskFailureNotificationEmail(reloadParams) { executionStatusText: scriptLogData.executionStatusText, executionDetails: scriptLogData.executionDetails, scriptLogSize: scriptLogData.scriptLogSize, + scriptLogSizeRows: scriptLogData.scriptLogSizeRows, + scriptLogSizeCharacters: scriptLogData.scriptLogSizeCharacters, scriptLogHead: scriptLogData.scriptLogHead, scriptLogTail: scriptLogData.scriptLogTail, scriptLogTailCount: scriptLogData.scriptLogTailCount, @@ -855,6 +857,8 @@ export async function sendReloadTaskAbortedNotificationEmail(reloadParams) { executionStatusText: scriptLogData.executionStatusText, executionDetails: scriptLogData.executionDetails, scriptLogSize: scriptLogData.scriptLogSize, + scriptLogSizeRows: scriptLogData.scriptLogSizeRows, + scriptLogSizeCharacters: scriptLogData.scriptLogSizeCharacters, scriptLogHead: scriptLogData.scriptLogHead, scriptLogTail: scriptLogData.scriptLogTail, scriptLogTailCount: scriptLogData.scriptLogTailCount, @@ -1098,6 +1102,8 @@ export async function sendReloadTaskSuccessNotificationEmail(reloadParams) { executionStatusText: scriptLogData.executionStatusText, executionDetails: scriptLogData.executionDetails, scriptLogSize: scriptLogData.scriptLogSize, + scriptLogSizeRows: scriptLogData.scriptLogSizeRows, + scriptLogSizeCharacters: scriptLogData.scriptLogSizeCharacters, scriptLogHead: scriptLogData.scriptLogHead, scriptLogTail: scriptLogData.scriptLogTail, scriptLogTailCount: scriptLogData.scriptLogTailCount, diff --git a/src/qrs_util/app_metadata.js b/src/qrs_util/app_metadata.js index 82cda792..a187d2e3 100644 --- a/src/qrs_util/app_metadata.js +++ b/src/qrs_util/app_metadata.js @@ -8,7 +8,7 @@ import globals from '../globals.js'; * @returns */ async function getAppMetadata(appId) { - globals.logger.debug(`GET APP METADATA: Retrieving metadata for app ${appId}`); + globals.logger.debug(`[QSEOW] GET APP METADATA: Retrieving metadata for app ${appId}`); try { // Get http headers from Butler config file @@ -26,10 +26,10 @@ async function getAppMetadata(appId) { // Get app metadata try { - globals.logger.debug(`GET APP METADATA: app/full?filter=id eq ${appId}`); + globals.logger.debug(`[QSEOW] GET APP METADATA: app/full?filter=id eq ${appId}`); const result = await qrsInstance.Get(`app/full?filter=id eq ${appId}`); - globals.logger.debug(`GET APP METADATA: Got response: ${result.statusCode}`); + globals.logger.debug(`[QSEOW] GET APP METADATA: Got response: ${result.statusCode}`); if (result.body.length === 1) { // Yes, the app exists. Return metadata for this app @@ -39,11 +39,11 @@ async function getAppMetadata(appId) { // The task does not exist return {}; } catch (err) { - globals.logger.error(`GET APP METADATA: Error while getting app metadata: ${err.message}`); - return []; + globals.logger.error(`[QSEOW] GET APP METADATA: Error while getting app metadata: ${err.message}`); + return false; } } catch (err) { - globals.logger.error(`GET APP METADATA: Error while getting app metadata: ${err}`); + globals.logger.error(`[QSEOW] GET APP METADATA: Error while getting app metadata: ${err}`); return false; } } diff --git a/src/udp/udp_handlers.js b/src/udp/udp_handlers.js index 18416ce0..aa3e04f3 100644 --- a/src/udp/udp_handlers.js +++ b/src/udp/udp_handlers.js @@ -28,7 +28,7 @@ import getTaskMetadata from '../qrs_util/task_metadata.js'; // Handler for failed scheduler initiated reloads const schedulerAborted = async (msg) => { globals.logger.verbose( - `TASKABORTED: Received reload aborted UDP message from scheduler: UDP msg=${msg[0]}, Host=${msg[1]}, App name=${msg[3]}, Task name=${msg[2]}, Log level=${msg[8]}, Log msg=${msg[10]}`, + `[QSEOW] TASKABORTED: Received reload aborted UDP message from scheduler: UDP msg=${msg[0]}, Host=${msg[1]}, App name=${msg[3]}, Task name=${msg[2]}, Log level=${msg[8]}, Log msg=${msg[10]}`, ); // Get script log for failed reloads. @@ -42,13 +42,20 @@ const schedulerAborted = async (msg) => { ) { scriptLog = await getScriptLog(msg[5], 1, 1); - globals.logger.verbose(`Script log for aborted reload retrieved`); + globals.logger.verbose(`[QSEOW] Script log for aborted reload retrieved`); } // TOOD: Add check if task exists in QRS // Get app metadata from QRS + // Returns false if app metadata retrieval fails, JSON object if successful const appMetadata = await getAppMetadata(msg[6]); + // If we could not get app metadata from QRS, that is a problem. Log it and return + if (appMetadata === false) { + globals.logger.error(`[QSEOW] TASKABORTED: Could not get app metadata for app ${msg[6]}. Aborting further processing`); + return; + } + // Get tags for the app that failed reloading // Tags are found in appMetadata.tags, which is an array of objects with the following properties: // - id @@ -56,7 +63,7 @@ const schedulerAborted = async (msg) => { // // Create an array of tag names only const appTags = appMetadata.tags.map((tag) => tag.name); - globals.logger.verbose(`Tags for app ${msg[6]}: ${JSON.stringify(appTags, null, 2)}`); + globals.logger.verbose(`[QSEOW] Tags for app ${msg[6]}: ${JSON.stringify(appTags, null, 2)}`); // Get app custom properties // They are found in appMetadata.customProperties, which is an array of objects with the following properties: @@ -76,7 +83,7 @@ const schedulerAborted = async (msg) => { // Get tags for the task that failed reloading const taskTags = taskMetadata.tags.map((tag) => tag.name); - globals.logger.verbose(`Tags for task ${msg[5]}: ${JSON.stringify(taskTags, null, 2)}`); + globals.logger.verbose(`[QSEOW] Tags for task ${msg[5]}: ${JSON.stringify(taskTags, null, 2)}`); // Get reload task custom properties const taskCustomProperties = taskMetadata.customProperties.map((cp) => ({ @@ -268,7 +275,7 @@ const schedulerAborted = async (msg) => { globals.mqttClient.publish(globals.config.get('Butler.mqttConfig.taskAbortedTopic'), msg[2]); } else { globals.logger.warn( - `MQTT: MQTT client not connected. Unable to publish message to topic ${globals.config.get( + `[QSEOW] MQTT: MQTT client not connected. Unable to publish message to topic ${globals.config.get( 'Butler.mqttConfig.taskAbortedTopic', )}`, ); @@ -314,11 +321,11 @@ const schedulerFailed = async (msg) => { globals.config.get('Butler.emailNotification.enable') === true ) { scriptLog = await getScriptLog(msg[5], 0, 0); - globals.logger.verbose(`Script log for failed reload retrieved`); + globals.logger.verbose(`[QSEOW] Script log for failed reload retrieved`); } globals.logger.verbose( - `TASKFAILURE: Received reload failed UDP message from scheduler: UDP msg=${msg[0]}, Host=${msg[1]}, App name=${msg[3]}, Task name=${msg[2]}, Log level=${msg[8]}, Log msg=${msg[10]}`, + `[QSEOW] TASKFAILURE: Received reload failed UDP message from scheduler: UDP msg=${msg[0]}, Host=${msg[1]}, App name=${msg[3]}, Task name=${msg[2]}, Log level=${msg[8]}, Log msg=${msg[10]}`, ); // First field in message (msg[0]) is message category (this is the modern/recent message format) @@ -326,6 +333,12 @@ const schedulerFailed = async (msg) => { // Get app metadata from QRS const appMetadata = await getAppMetadata(msg[6]); + // If we could not get app metadata from QRS, that is a problem. Log it and return + if (appMetadata === false) { + globals.logger.error(`[QSEOW] TASKFAILURE: Could not get app metadata for app ${msg[6]}. Aborting further processing`); + return; + } + // Get tags for the app that failed reloading // Tags are found in appMetadata.tags, which is an array of objects with the following properties: // - id @@ -333,7 +346,7 @@ const schedulerFailed = async (msg) => { // // Create an array of tag names only const appTags = appMetadata.tags.map((tag) => tag.name); - globals.logger.verbose(`Tags for app ${msg[6]}: ${JSON.stringify(appTags, null, 2)}`); + globals.logger.verbose(`[QSEOW] Tags for app ${msg[6]}: ${JSON.stringify(appTags, null, 2)}`); // Get app custom properties // They are found in appMetadata.customProperties, which is an array of objects with the following properties: @@ -353,7 +366,7 @@ const schedulerFailed = async (msg) => { // Get tags for the task that failed reloading const taskTags = taskMetadata.tags.map((tag) => tag.name); - globals.logger.verbose(`Tags for task ${msg[5]}: ${JSON.stringify(taskTags, null, 2)}`); + globals.logger.verbose(`[QSEOW] Tags for task ${msg[5]}: ${JSON.stringify(taskTags, null, 2)}`); // Get reload task custom properties const taskCustomProperties = taskMetadata.customProperties.map((cp) => ({ @@ -591,7 +604,7 @@ const schedulerFailed = async (msg) => { globals.mqttClient.publish(globals.config.get('Butler.mqttConfig.taskFailureTopic'), msg[2]); } else { globals.logger.warn( - `MQTT: MQTT client not connected. Unable to publish message to topic ${globals.config.get( + `[QSEOW] MQTT: MQTT client not connected. Unable to publish message to topic ${globals.config.get( 'Butler.mqttConfig.taskFailureTopic', )}`, ); @@ -628,7 +641,7 @@ const schedulerFailed = async (msg) => { // -------------------------------------------------------- const schedulerReloadTaskSuccess = async (msg) => { globals.logger.verbose( - `RELOAD TASK SUCCESS: Received reload task success UDP message from scheduler: UDP msg=${msg[0]}, Host=${msg[1]}, App name=${msg[3]}, Task name=${msg[2]}, Log level=${msg[8]}, Log msg=${msg[10]}`, + `[QSEOW] RELOAD TASK SUCCESS: Received reload task success UDP message from scheduler: UDP msg=${msg[0]}, Host=${msg[1]}, App name=${msg[3]}, Task name=${msg[2]}, Log level=${msg[8]}, Log msg=${msg[10]}`, ); const reloadTaskId = msg[5]; @@ -636,7 +649,7 @@ const schedulerReloadTaskSuccess = async (msg) => { // Does task ID exist in Sense? const taskExists = await doesTaskExist(reloadTaskId); if (taskExists.exists !== true) { - globals.logger.warn(`RELOAD TASK SUCCESS: Task ID ${reloadTaskId} does not exist in Sense`); + globals.logger.warn(`[QSEOW] RELOAD TASK SUCCESS: Task ID ${reloadTaskId} does not exist in Sense`); return false; } @@ -682,12 +695,18 @@ const schedulerReloadTaskSuccess = async (msg) => { globals.config.get('Butler.emailNotification.reloadTaskSuccess.enable') === true) ) { scriptLog = await getScriptLog(reloadTaskId, 0, 0); - globals.logger.verbose(`Script log for successful reload retrieved`); + globals.logger.verbose(`[QSEOW] Script log for successful reload retrieved`); } // Get app metadata from QRS const appMetadata = await getAppMetadata(msg[6]); + // If we could not get app metadata from QRS, that is a problem. Log it and return + if (appMetadata === false) { + globals.logger.error(`[QSEOW] RELOAD TASK SUCCESS: Could not get app metadata for app ${msg[6]}. Aborting further processing`); + return; + } + // Get tags for the app that failed reloading // Tags are found in appMetadata.tags, which is an array of objects with the following properties: // - id @@ -695,7 +714,7 @@ const schedulerReloadTaskSuccess = async (msg) => { // // Create an array of tag names only const appTags = appMetadata.tags.map((tag) => tag.name); - globals.logger.verbose(`Tags for app ${msg[6]}: ${JSON.stringify(appTags, null, 2)}`); + globals.logger.verbose(`[QSEOW] Tags for app ${msg[6]}: ${JSON.stringify(appTags, null, 2)}`); // Get app custom properties // They are found in appMetadata.customProperties, which is an array of objects with the following properties: @@ -715,7 +734,7 @@ const schedulerReloadTaskSuccess = async (msg) => { // Get tags for the task that failed reloading const taskTags = taskMetadata.tags.map((tag) => tag.name); - globals.logger.verbose(`Tags for task ${msg[5]}: ${JSON.stringify(taskTags, null, 2)}`); + globals.logger.verbose(`[QSEOW] Tags for task ${msg[5]}: ${JSON.stringify(taskTags, null, 2)}`); // Get reload task custom properties const taskCustomProperties = taskMetadata.customProperties.map((cp) => ({ @@ -750,12 +769,12 @@ const schedulerReloadTaskSuccess = async (msg) => { taskInfo.executionDuration.seconds === 0 ) { globals.logger.warn( - `RELOAD TASK SUCCESS: Task info for reload task ${reloadTaskId} retrieved successfully after ${retryCount} attempts, but duration is 0 seconds. This is likely caused by the QRS not having updated the execution details yet.`, + `[QSEOW] RELOAD TASK SUCCESS: Task info for reload task ${reloadTaskId} retrieved successfully after ${retryCount} attempts, but duration is 0 seconds. This is likely caused by the QRS not having updated the execution details yet.`, ); } globals.logger.debug( - `RELOAD TASK SUCCESS: Task info for reload task ${reloadTaskId} retrieved successfully after ${retryCount} attempts`, + `[QSEOW] RELOAD TASK SUCCESS: Task info for reload task ${reloadTaskId} retrieved successfully after ${retryCount} attempts`, ); break; } @@ -763,7 +782,7 @@ const schedulerReloadTaskSuccess = async (msg) => { retryCount += 1; globals.logger.verbose( - `RELOAD TASK SUCCESS: Unable to get task info for reload task ${reloadTaskId}. Attempt ${retryCount} of 5. Waiting 1 second before trying again`, + `[QSEOW] RELOAD TASK SUCCESS: Unable to get task info for reload task ${reloadTaskId}. Attempt ${retryCount} of 5. Waiting 1 second before trying again`, ); // eslint-disable-next-line no-await-in-loop @@ -772,11 +791,13 @@ const schedulerReloadTaskSuccess = async (msg) => { if (!taskInfo) { globals.logger.warn( - `RELOAD TASK SUCCESS: Unable to get task info for reload task ${reloadTaskId}. Not storing task info in InfluxDB`, + `[QSEOW] RELOAD TASK SUCCESS: Unable to get task info for reload task ${reloadTaskId}. Not storing task info in InfluxDB`, ); return false; } - globals.logger.verbose(`RELOAD TASK SUCCESS: Task info for reload task ${reloadTaskId}: ${JSON.stringify(taskInfo, null, 2)}`); + globals.logger.verbose( + `[QSEOW] RELOAD TASK SUCCESS: Task info for reload task ${reloadTaskId}: ${JSON.stringify(taskInfo, null, 2)}`, + ); // Get app/task tags so they can be included in data sent to alert destinations let appTags = []; @@ -784,11 +805,11 @@ const schedulerReloadTaskSuccess = async (msg) => { // Get tags for the app that was reloaded appTags = await getAppTags(msg[6]); - globals.logger.verbose(`Tags for app ${msg[6]}: ${JSON.stringify(appTags, null, 2)}`); + globals.logger.verbose(`[QSEOW] Tags for app ${msg[6]}: ${JSON.stringify(appTags, null, 2)}`); // Get tags for the task that finished reloading successfully taskTags = await getTaskTags(msg[5]); - globals.logger.verbose(`Tags for task ${msg[5]}: ${JSON.stringify(taskTags, null, 2)}`); + globals.logger.verbose(`[QSEOW] Tags for task ${msg[5]}: ${JSON.stringify(taskTags, null, 2)}`); // Post to InfluxDB when a reload task has finished successfully if ( @@ -817,10 +838,10 @@ const schedulerReloadTaskSuccess = async (msg) => { qs_taskMetadata: taskMetadata, }); - globals.logger.info(`RELOAD TASK SUCCESS: Reload info for reload task ${reloadTaskId}, "${msg[2]}" stored in InfluxDB`); + globals.logger.info(`[QSEOW] RELOAD TASK SUCCESS: Reload info for reload task ${reloadTaskId}, "${msg[2]}" stored in InfluxDB`); } } else { - globals.logger.verbose(`RELOAD TASK SUCCESS: Not storing task info in InfluxDB`); + globals.logger.verbose(`[QSEOW] RELOAD TASK SUCCESS: Not storing task info in InfluxDB`); } // Should we send email notification? @@ -861,7 +882,7 @@ const udpInitTaskErrorServer = () => { globals.udpServerReloadTaskSocket.on('listening', (message, remote) => { const address = globals.udpServerReloadTaskSocket.address(); - globals.logger.info(`TASKFAILURE: UDP server listening on ${address.address}:${address.port}`); + globals.logger.info(`[QSEOW] TASKFAILURE: UDP server listening on ${address.address}:${address.port}`); // Publish MQTT message that UDP server has started if (globals.config.has('Butler.mqttConfig.enable') && globals.config.get('Butler.mqttConfig.enable') === true) { @@ -869,7 +890,7 @@ const udpInitTaskErrorServer = () => { globals.mqttClient.publish(globals.config.get('Butler.mqttConfig.taskFailureServerStatusTopic'), 'start'); } else { globals.logger.warn( - `UDP SERVER INIT: MQTT client not connected. Unable to publish message to topic ${globals.config.get( + `[QSEOW] UDP SERVER INIT: MQTT client not connected. Unable to publish message to topic ${globals.config.get( 'Butler.mqttConfig.taskFailureServerStatusTopic', )}`, ); @@ -882,7 +903,7 @@ const udpInitTaskErrorServer = () => { globals.udpServerReloadTaskSocket.on('error', (message, remote) => { try { const address = globals.udpServerReloadTaskSocket.address(); - globals.logger.error(`TASKFAILURE: UDP server error on ${address.address}:${address.port}`); + globals.logger.error(`[QSEOW] TASKFAILURE: UDP server error on ${address.address}:${address.port}`); // Publish MQTT message that UDP server has reported an error if (globals.config.has('Butler.mqttConfig.enable') && globals.config.get('Butler.mqttConfig.enable') === true) { @@ -890,14 +911,14 @@ const udpInitTaskErrorServer = () => { globals.mqttClient.publish(globals.config.get('Butler.mqttConfig.taskFailureServerStatusTopic'), 'error'); } else { globals.logger.warn( - `UDP SERVER ERROR: MQTT client not connected. Unable to publish message to topic ${globals.config.get( + `[QSEOW] UDP SERVER ERROR: MQTT client not connected. Unable to publish message to topic ${globals.config.get( 'Butler.mqttConfig.taskFailureServerStatusTopic', )}`, ); } } } catch (err) { - globals.logger.error(`TASKFAILURE: Error in UDP error handler: ${err}`); + globals.logger.error(`[QSEOW] TASKFAILURE: Error in UDP error handler: ${err}`); } }); @@ -971,7 +992,7 @@ const udpInitTaskErrorServer = () => { // mag[8] : Message try { - globals.logger.debug(`UDP HANDLER: UDP message received: ${message.toString()}`); + globals.logger.debug(`[QSEOW] UDP HANDLER: UDP message received: ${message.toString()}`); const msg = message.toString().split(';'); @@ -982,15 +1003,15 @@ const udpInitTaskErrorServer = () => { // There should be exactly 11 fields in the message if (msg.length !== 9) { globals.logger.warn( - `UDP HANDLER ENGINE RELOAD FAILED: Invalid number of fields in UDP message. Expected 9, got ${msg.length}.`, + `[QSEOW] UDP HANDLER ENGINE RELOAD FAILED: Invalid number of fields in UDP message. Expected 9, got ${msg.length}.`, ); - globals.logger.warn(`UDP HANDLER ENGINE RELOAD FAILED: Incoming log message was:\n${message.toString()}`); - globals.logger.warn(`UDP HANDLER ENGINE RELOAD FAILED: Aborting processing of this message.`); + globals.logger.warn(`[QSEOW] UDP HANDLER ENGINE RELOAD FAILED: Incoming log message was:\n${message.toString()}`); + globals.logger.warn(`[QSEOW] UDP HANDLER ENGINE RELOAD FAILED: Aborting processing of this message.`); return; } globals.logger.verbose( - `UDP HANDLER ENGINE RELOAD FAILED: Received reload failed UDP message from engine: Host=${msg[1]}, AppID=${msg[2]}, User directory=${msg[4]}, User=${msg[5]}`, + `[QSEOW] UDP HANDLER ENGINE RELOAD FAILED: Received reload failed UDP message from engine: Host=${msg[1]}, AppID=${msg[2]}, User directory=${msg[4]}, User=${msg[5]}`, ); } else if (msg[0].toLowerCase() === '/scheduler-reload-failed/') { // Scheduler log appender detecting failed scheduler-started reload @@ -999,10 +1020,10 @@ const udpInitTaskErrorServer = () => { // There should be exactly 11 fields in the message if (msg.length !== 11) { globals.logger.warn( - `UDP HANDLER SCHEDULER RELOAD FAILED: Invalid number of fields in UDP message. Expected 11, got ${msg.length}.`, + `[QSEOW] UDP HANDLER SCHEDULER RELOAD FAILED: Invalid number of fields in UDP message. Expected 11, got ${msg.length}.`, ); - globals.logger.warn(`UDP HANDLER SCHEDULER RELOAD FAILED: Incoming log message was:\n${message.toString()}`); - globals.logger.warn(`UDP HANDLER SCHEDULER RELOAD FAILED: Aborting processing of this message.`); + globals.logger.warn(`[QSEOW] UDP HANDLER SCHEDULER RELOAD FAILED: Incoming log message was:\n${message.toString()}`); + globals.logger.warn(`[QSEOW] UDP HANDLER SCHEDULER RELOAD FAILED: Aborting processing of this message.`); return; } @@ -1014,10 +1035,10 @@ const udpInitTaskErrorServer = () => { // There should be exactly 11 fields in the message if (msg.length !== 11) { globals.logger.warn( - `UDP HANDLER SCHEDULER RELOAD ABORTED: Invalid number of fields in UDP message. Expected 11, got ${msg.length}.`, + `[QSEOW] UDP HANDLER SCHEDULER RELOAD ABORTED: Invalid number of fields in UDP message. Expected 11, got ${msg.length}.`, ); - globals.logger.warn(`UDP HANDLER SCHEDULER RELOAD ABORTED: Incoming log message was:\n${message.toString()}`); - globals.logger.warn(`UDP HANDLER SCHEDULER RELOAD ABORTED: Aborting processing of this message.`); + globals.logger.warn(`[QSEOW] UDP HANDLER SCHEDULER RELOAD ABORTED: Incoming log message was:\n${message.toString()}`); + globals.logger.warn(`[QSEOW] UDP HANDLER SCHEDULER RELOAD ABORTED: Aborting processing of this message.`); return; } @@ -1029,19 +1050,21 @@ const udpInitTaskErrorServer = () => { // There should be exactly 11 fields in the message if (msg.length !== 11) { globals.logger.warn( - `UDP HANDLER SCHEDULER RELOAD TASK SUCCESS: Invalid number of fields in UDP message. Expected 11, got ${msg.length}.`, + `[QSEOW] UDP HANDLER SCHEDULER RELOAD TASK SUCCESS: Invalid number of fields in UDP message. Expected 11, got ${msg.length}.`, + ); + globals.logger.warn( + `[QSEOW] UDP HANDLER SCHEDULER RELOAD TASK SUCCESS: Incoming log message was:\n${message.toString()}`, ); - globals.logger.warn(`UDP HANDLER SCHEDULER RELOAD TASK SUCCESS: Incoming log message was:\n${message.toString()}`); - globals.logger.warn(`UDP HANDLER SCHEDULER RELOAD TASK SUCCESS: Aborting processing of this message.`); + globals.logger.warn(`[QSEOW] UDP HANDLER SCHEDULER RELOAD TASK SUCCESS: Aborting processing of this message.`); return; } schedulerReloadTaskSuccess(msg); } else { - globals.logger.warn(`UDP HANDLER: Unknown UDP message format: "${msg[0]}"`); + globals.logger.warn(`[QSEOW] UDP HANDLER: Unknown UDP message format: "${msg[0]}"`); } } catch (err) { - globals.logger.error(`UDP HANDLER: Failed processing log event. No action will be taken for this event. Error: ${err}`); - globals.logger.error(`UDP HANDLER: Incoming log message was\n${message}`); + globals.logger.error(`[QSEOW] UDP HANDLER: Failed processing log event. No action will be taken for this event. Error: ${err}`); + globals.logger.error(`[QSEOW] UDP HANDLER: Incoming log message was\n${message}`); } }); };