Skip to content

Commit c3c291d

Browse files
author
Dave Lahr
committed
website/alerts.js: add more logging
1 parent 51478c3 commit c3c291d

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

website/alerts.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ const alertEmailAddresses = '[email protected], [email protected]'; //lahr
1010
exports.thermostatDeviceTypeIds = {2:null, 3:null};
1111

1212

13+
const consoleLogAlertInfo = function(alertInfo) {
14+
console.log('alerts consoleLogAlertInfo');
15+
for (id in alertInfo) {
16+
console.log('id: ' + id + ' alertInfo[id]: ' + JSON.stringify(alertInfo[id]));
17+
}
18+
};
19+
20+
1321
//typically called with:
1422
//alertInfo as object that is built with buildInitialAlertInfo and then updated with updateAlertInfo
1523
//alertsConfig loaded from config file, alerts section
@@ -19,6 +27,7 @@ exports.thermostatDeviceTypeIds = {2:null, 3:null};
1927
//
2028
exports.alertLoop = function(alertInfo, alertsConfig, sendAlertFunction, checksFunction, sleepTime) {
2129
console.log('alerts alertLoop');
30+
consoleLogAlertInfo(alertInfo);
2231

2332
if (!('loopIndex' in alertInfo)) {
2433
alertInfo.loopIndex = 0;
@@ -42,7 +51,7 @@ exports.alertLoop = function(alertInfo, alertsConfig, sendAlertFunction, checksF
4251

4352
exports.buildInitialAlertInfo = function(db, callback) {
4453
database.getDeviceMetadata(db, function(deviceMetadata) {
45-
database.getAlertSettings(db, function(alertSettings){
54+
database.getAlertSettings(db, function(alertSettings) {
4655
for (var id in deviceMetadata) {
4756
var curDevice = deviceMetadata[id];
4857
curDevice.lastTime = null;
@@ -186,6 +195,7 @@ exports.checkForTemperatureAlert = function(deviceAlertInfo) {
186195
//sendAlertFunction as sendAlerts function in this module
187196
exports.checkForAlerts = function(alertInfo, sendAlertFunction, alertsConfig) {
188197
console.log('alerts checkForAlerts');
198+
consoleLogAlertInfo(alertInfo);
189199

190200
if (sendAlertFunction == 'undefined' || sendAlertFunction == null) {
191201
sendAlertFunction = exports.SendAlert;
@@ -195,6 +205,7 @@ exports.checkForAlerts = function(alertInfo, sendAlertFunction, alertsConfig) {
195205
var alerts = [];
196206
for (var id in alertInfo) {
197207
var deviceAlertInfo = alertInfo[id];
208+
console.log('checking all alerts for id: ' + id + ' deviceAlertInfo: ' + JSON.stringify(deviceAlertInfo));
198209

199210
for (var i = 0; i < alertFunctions.length; i++) {
200211
var aFun = alertFunctions[i];
@@ -206,6 +217,9 @@ exports.checkForAlerts = function(alertInfo, sendAlertFunction, alertsConfig) {
206217
alerts.push(r);
207218
}
208219
}
220+
221+
console.log('finished checking for id: ' + id);
222+
console.log();
209223
}
210224

211225
if (alerts.length > 0) {

0 commit comments

Comments
 (0)