I tried to create a lambda function using node.js. w wrote code in C code and convert it to node library using node-gyp. lambda function perfectly working. but it print only node.js console.log statements.
This is my node.js code
'use strict';
console.log('Loading function');
exports.handler = (event, context, callback) => {
var addon = require('./build/Release/testLibraryfromCcode');
addon.sayHello();
console.log("Completed");
}
This is my C code
int sayHello()
{
printf("Haaaaaaaaaaaaai\n");
fflush(stdout);
return 0;
}
I got output like this from lambda test console
TART RequestId: 3e8cd5ff-2d41-11e6-af8f-ada8f1249113 Version: $LATEST
2016-06-08T06:21:32.779Z 3e8cd5ff-2d41-11e6-af8f-ada8f1249113 Loading function
2016-06-08T06:21:32.779Z 3e8cd5ff-2d41-11e6-af8f-ada8f1249113 Completed
Haaaaai print is missing. i need to print printf statements in my C code. if any idea?
This code is working. fflush(stdout) is enogh for printing.
int sayHello()
{
printf("Haaaaaaaaaaaaai\n");
fflush(stdout);
return 0;
}
But, aws lamda cannot print library prints directly on web console. We need to install awslogs for waching full logs.
install awslogs
sudo pip install awslogs
for Waching logs.
awslogs get /aws/lambda/lambdaFunctionName --start="3h"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With