-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can we use it inside AWS Lambda? #193
Comments
Did you try running one of the examples? This one has been specifically made fo AWS Lambda usage. |
hi @lazywithclass, I'm really not sure what Ive been doing wrong. I've tried to follow the example that you provided. I really need your advice on this :( cause I don't see the error the and this is what my main lambda file looks like and this is what Ive got inside cloudwatch using the example you provided from this one |
Hello, it's been years since I've used this module in production, expecially in Lambda: to reproduce the problem you're facing I should just write what's in your screenshots, right? Thanks! |
Hi @lazywithclass , yup sure. thanks for the reply :) and yes, to reproduce, you can just copy and paste the code back just need to add in this line of tag (I'm using serverless framework btw)
the main lambda handler (async operation)
the info logger file
from what Ive encounter also, because of lambda async process, the winston logger don't have enough time to Ive also have try to use do let me know if you need me to try anything or test anything. I'll surely try and help you with what I can and know :) |
I can confirm that this does not work when deploying via Lambda. Unfortunately I deploy via Docker containers to Lambda therefore I am not able to see if there are any errors unless they are console logged which I have tried to do but have not seen any. |
It definitely could be used inside AWS Lambda, at some point I wrote a function to be used inside such a service (see an example
|
@cheshu21 async log(info: any, callback: any) {
setImmediate(() => {
this.emit('logged', info);
});
const command3 = new PutLogEventsCommand({
//config
});
console.log('command3', command3);
try {
await new Promise((resolve) => setTimeout(resolve, 0));
const result = await client.send(command);
} catch (err) {
console.log('failed');
}
callback();
}
This makes that the process doesn't exit and the logger does not finish the job. Adding a timeout to the event loop makes it so. |
This issue could be solved by changing
|
I am trying to use Winston Cloudwatch inside my Aws Lambda function but My log stream and Log groups are not created.
Could you please help me with this ?
The text was updated successfully, but these errors were encountered: