Skip to content

Commit

Permalink
chore: log encrypt sub ID with request meta (#1049)
Browse files Browse the repository at this point in the history
  • Loading branch information
mantariksh authored Jan 26, 2021
1 parent 089fa17 commit b9a2676
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/app/controllers/encrypt-submissions.server.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ function onEncryptSubmissionFailure(err, req, res, submission) {
*/
exports.saveResponseToDb = function (req, res, next) {
const { form, formData, attachmentData } = req
const logMeta = {
action: 'saveResponseToDb',
formId: form._id,
...createReqMeta(req),
}
const { verified } = res.locals
let attachmentMetadata = new Map()
let attachmentUploadPromises = []
Expand Down Expand Up @@ -95,10 +100,7 @@ exports.saveResponseToDb = function (req, res, next) {
.catch((err) => {
logger.error({
message: 'Attachment upload error',
meta: {
action: 'saveResponseToDb',
...createReqMeta(req),
},
meta: logMeta,
error: err,
})
return onEncryptSubmissionFailure(err, req, res, submission)
Expand All @@ -121,6 +123,13 @@ exports.saveResponseToDb = function (req, res, next) {
return submission.save()
})
.then((savedSubmission) => {
logger.info({
message: 'Saved submission to MongoDB',
meta: {
...logMeta,
submissionId: savedSubmission._id,
},
})
req.submission = savedSubmission
return next()
})
Expand Down

0 comments on commit b9a2676

Please sign in to comment.