Skip to content

Commit

Permalink
log events better
Browse files Browse the repository at this point in the history
  • Loading branch information
mathcoll committed Jan 2, 2022
1 parent 2ef5f38 commit 9a83ee6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
22 changes: 11 additions & 11 deletions t6console.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ t6console.critical = function(...criticalmessage) {
if ( logAuditOnError ) {
t6events.addAudit("t6App", `t6console.critical: ${criticalmessage}`, "", "", {"status": "500", error_id: "00001"});
}
var envelope = {
from: from,
bcc: bcc,
to: bcc,
user_id: bcc,
subject: `Critical Error on t6 ${app.get("env")}`,
text: `${criticalmessage}`,
html: `${criticalmessage}`
};
if ( sendMailOnCriticalError ) {
if ( sendMailOnCriticalError && criticalmessage ) {
var envelope = {
from: from,
bcc: bcc,
to: bcc,
user_id: bcc,
subject: `Critical Error on t6 ${app.get("env")}`,
text: `${criticalmessage}`,
html: `${criticalmessage}`
};
t6mailer.sendMail(envelope);
}
if ( sendTextMessageOnCriticalError ) {
if ( sendTextMessageOnCriticalError && twilioSettings.accountSid && twilioSettings.authToken && event.params.to) {
const clientTwilio = new twilio(twilioSettings.accountSid, twilioSettings.authToken);
clientTwilio.messages
.create({
Expand Down
14 changes: 2 additions & 12 deletions t6decisionrules.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ t6decisionrules.checkRulesFromUser = function(user_id, payload) {
t6console.debug("pushSubscription is now disabled on User", error);
}
} else {
t6console.error("No user or no pushSubscription found, can't sendPush");
t6console.error("No user or no pushSubscription found, can't sendPesh");
}
} else {
t6console.warn(`No matching EventType: ${event.type}`);
Expand All @@ -418,19 +418,9 @@ t6decisionrules.checkRulesFromUser = function(user_id, payload) {
});
engine.run(payload);
}).catch((err) => {
var envelope = {
from: from,
to: bcc,
user_id: payload.user_id?payload.user_id:to,
subject: "dbInfluxDB ERR on decisionRule (checkRulesFromUser)",
text: "Html email client is required",
html: err
};
t6console.error("dbInfluxDB ERR on decisionRule (checkRulesFromUser)", err);
t6console.critical("dbInfluxDB ERR on decisionRule (checkRulesFromUser)", err);
t6console.debug("ERR on decisionRule (checkRulesFromUser) :");
t6console.debug("payload", payload);
t6console.debug("envelope", envelope);
t6mailer.sendMail(envelope);
});
}; // t6decisionrules.checkRulesFromUser

Expand Down

0 comments on commit 9a83ee6

Please sign in to comment.