From 64798147799422cb4bf0ed4e36b921661153ba1c Mon Sep 17 00:00:00 2001 From: Timothee Groleau Date: Fri, 19 Apr 2024 12:34:03 +0800 Subject: [PATCH] ISOM-951: Better cloudmersive logging (#1323) * fix: better logging for cloudmersive errors * fix: better logging for cloudmersive success --- .../fileServices/MdPageServices/MediaFileService.js | 7 ++++++- src/utils/file-upload-utils.js | 13 +++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/services/fileServices/MdPageServices/MediaFileService.js b/src/services/fileServices/MdPageServices/MediaFileService.js index 4e2d1742c..d8cff85bc 100644 --- a/src/services/fileServices/MdPageServices/MediaFileService.js +++ b/src/services/fileServices/MdPageServices/MediaFileService.js @@ -36,7 +36,12 @@ class MediaFileService { const cmConfig = isCloudmersiveEnabled(sessionData.growthbook) if (cmConfig.is_enabled) { const virusScanRes = await scanFileForVirus(fileBuffer, cmConfig.timeout) - logger.info(`File scan result: ${virusScanRes.CleanResult}`) + logger.info({ + message: "File scan result", + meta: { + virusScanRes, + }, + }) if (!virusScanRes || !virusScanRes.CleanResult) { throw new BadRequestError("File did not pass virus scan") } diff --git a/src/utils/file-upload-utils.js b/src/utils/file-upload-utils.js index d77170b85..445f49627 100644 --- a/src/utils/file-upload-utils.js +++ b/src/utils/file-upload-utils.js @@ -44,11 +44,16 @@ const scanFileForVirus = (fileBuffer, timeout) => { defaultCloudmersiveClient.timeout = timeout } return new Promise((success, failure) => { - apiInstance.scanFile(fileBuffer, (error, data) => { + apiInstance.scanFile(fileBuffer, (error, data, response) => { if (error) { - logger.error( - `Error when calling Cloudmersive Virus Scan API: ${error.message}` - ) + logger.error({ + message: "Error when calling Cloudmersive Virus Scan API", + error, + meta: { + data, + headers: response?.headers, + }, + }) failure(error) } else { logger.info("Cloudmersive Virus Scan API called successfully")