mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
Added logging
This commit is contained in:
@@ -16,29 +16,33 @@ function init (env, ctx) {
|
||||
}
|
||||
if (metrics) {
|
||||
for (var i = 0, len = metrics.length; i < len; i++) {
|
||||
if (!intentHandlers[intent]) {
|
||||
intentHandlers[intent] = {};
|
||||
}
|
||||
if (!intentHandlers[intent][metrics[i]]) {
|
||||
intentHandlers[intent][metrics[i]] = {};
|
||||
}
|
||||
console.log('Storing handler for intent \'' + intent + '\' for metric \'' + metrics[i] + '\'');
|
||||
intentHandlers[intent][metrics[i]].handler = handler;
|
||||
}
|
||||
} else {
|
||||
console.log('Storing handler for intent \'' + intent + '\'');
|
||||
intentHandlers[intent].handler = handler;
|
||||
}
|
||||
};
|
||||
|
||||
// This function retrieves a handler based on the intent name and metric requested.
|
||||
alexa.getIntentHandler = function getIntentHandler(intentName, metric) {
|
||||
console.log('Looking for handler for intent \'' + intentName + '\' for metric \'' + metric + '\'');
|
||||
if (intentName && intentHandlers[intentName]) {
|
||||
if (intentHandlers[intentName][metric] && intentHandlers[intentName][metric].handler) {
|
||||
console.log('Found!');
|
||||
return intentHandlers[intentName][metric].handler
|
||||
} else if (intentHandlers[intentName].handler) {
|
||||
console.log('Found!');
|
||||
return intentHandlers[intentName].handler;
|
||||
}
|
||||
console.log('Not found!');
|
||||
return null;
|
||||
} else {
|
||||
console.log('Not found!');
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -16,29 +16,33 @@ function init (env, ctx) {
|
||||
}
|
||||
if (metrics) {
|
||||
for (var i = 0, len = metrics.length; i < len; i++) {
|
||||
if (! intentHandlers[intent]) {
|
||||
intentHandlers[intent] = {};
|
||||
}
|
||||
if (!intentHandlers[intent][metrics[i]]) {
|
||||
intentHandlers[intent][metrics[i]] = {};
|
||||
}
|
||||
console.log('Storing handler for intent \'' + intent + '\' for metric \'' + metrics[i] + '\'');
|
||||
intentHandlers[intent][metrics[i]].handler = handler;
|
||||
}
|
||||
} else {
|
||||
console.log('Storing handler for intent \'' + intent + '\'');
|
||||
intentHandlers[intent].handler = handler;
|
||||
}
|
||||
};
|
||||
|
||||
// This function retrieves a handler based on the intent name and metric requested.
|
||||
googleHome.getIntentHandler = function getIntentHandler(intentName, metric) {
|
||||
console.log('Looking for handler for intent \'' + intentName + '\' for metric \'' + metric + '\'');
|
||||
if (intentName && intentHandlers[intentName]) {
|
||||
if (intentHandlers[intentName][metric] && intentHandlers[intentName][metric].handler) {
|
||||
console.log('Found!');
|
||||
return intentHandlers[intentName][metric].handler
|
||||
} else if (intentHandlers[intentName].handler) {
|
||||
console.log('Found!');
|
||||
return intentHandlers[intentName].handler;
|
||||
}
|
||||
console.log('Not found!');
|
||||
return null;
|
||||
} else {
|
||||
console.log('Not found!');
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user