Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISOM-951: Better cloudmersive logging #1323

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to note: I'm not sure if data will be populated on error (as opposed to being null/undefined, and we'd have to retrieve the response body from the response object ourselves) 🤔

But I reckon it's not very important just yet, this PR already logs a lot more info that we had before, and we can iterate to get the body later.

headers: response?.headers,
},
})
failure(error)
} else {
logger.info("Cloudmersive Virus Scan API called successfully")
Expand Down
Loading