Skip to content

Commit

Permalink
ISOM-951: Better cloudmersive logging (#1323)
Browse files Browse the repository at this point in the history
* fix: better logging for cloudmersive errors

* fix: better logging for cloudmersive success
  • Loading branch information
timotheeg authored Apr 19, 2024
1 parent 4e6bc5e commit 6479814
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/services/fileServices/MdPageServices/MediaFileService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
13 changes: 9 additions & 4 deletions src/utils/file-upload-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 6479814

Please sign in to comment.