Tuesday, 4 April 2017

Using console.log and winston with BST (Alexa SDK)

I'm using BST to test the Lambdas, but it seems that the tool prevents me from directly printing to the console or logging to a file. If that's not correct, please let me know how I should fix my code. If that is indeed the case, how can I make it work?

In index.js, I have a very simple HelloWorldIntent that looks like below:

var handlers = {
    'HelloWorldIntent': function () {
        console.log('Print this');
        winston.info('info\'ing');
        this.emit(':tell', 'Hello, World!');
    }
};

When I place console.log and winston.info out of the handlers object (just somewhere in the global scope), and run the script directly on Node.js, they work as expected, so that's why I suspect BST is actively preventing the logging operations. Is that the case? If so, how can I work around it?

I run into this issue when testing with bst speak.

$ bst proxy lambda src/index.js
$ bst speak hello

The request and response JSON work fine.



via Posh_Pumpkin

No comments:

Post a Comment