Added logging

This commit is contained in:
inventor96
2019-09-07 23:55:26 -06:00
parent b3a47b36e0
commit 79f0217011
2 changed files with 14 additions and 6 deletions
+7 -3
View File
@@ -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;
}
};
+7 -3
View File
@@ -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;
}
};