Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 4e2fc58

Browse files
DanielBriertonWardormeur
authored andcommitted
Increased logging for email notifications (#412)
* Increased logging for email notifications * Log err/res within the final done for submit dojo
1 parent 4a8ff73 commit 4e2fc58

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

email-notifications.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,23 @@ module.exports = function (options) {
3030
var locale = args.locality;
3131
var code = args.code;
3232
if (options.sendemail && options.email) {
33+
logger.warn('email-notifications', JSON.stringify(args));
3334
emailCode = code + locale;
3435
if (!fs.existsSync(CpTranslations.getEmailTemplatePath(emailCode))) emailCode = code + 'en_US';
3536
if (!args.to) return done(null, {ok: false, why: 'No recipient set.'});
3637

3738
if (!bypassTranslation) {
3839
subjectTranslation = i18nHelper.getClosestTranslation(locale, subject);
3940
if (subjectTranslation === null) {
41+
logger.warn('email-notifications', JSON.stringify({
42+
ok: false,
43+
why: 'Invalid email subject.',
44+
args
45+
}));
4046
return done(null, {ok: false, why: 'Invalid email subject.'});
4147
}
4248
subject = subjectTranslation.fetch(subjectVariables);
4349
}
44-
logger.warn('email-notifications', JSON.stringify(args));
4550
seneca.act({
4651
role: 'mail', cmd: 'send',
4752
from: args.from || options.sendFrom,

lib/controllers/dojo/submit.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = function (args, done) {
1717
var env = seneca.options().env;
1818
var zenHostname = env.hostname;
1919
var protocol = env.protocol;
20+
const logger = require('cp-logs-lib')({ name: 'cp-dojos-service', level: 'warn' }).logger;
2021

2122
async.waterfall([
2223
// Set the initial dojo status : awaiting approval
@@ -79,8 +80,10 @@ module.exports = function (args, done) {
7980
payload: payload},
8081
function (err, res) {
8182
if (err) {
83+
logger.warn('submit-dojo', err);
8284
return cb(err);
8385
}
86+
logger.warn('submit-dojo', res);
8487
cb(null, savedDojo);
8588
});
8689
} else {

0 commit comments

Comments
 (0)