lazywithclass / winston-cloudwatch

Send logs to Amazon Cloudwatch using Winston.
MIT License
258 stars 104 forks source link

AWS Lambda only executing first CloudWatch transport #127

Open Bounteous17 opened 4 years ago

Bounteous17 commented 4 years ago

Hello, I am adding two winston-cloudwatch transports to my logger. Each logger transport have a different group pool name configured. When I am executing the application on my machine, the message is being logged on both CloudWatch pools located on AWS.

The issue comes when I try the same code inside a Lambda function deployed on AWS. Then the message is only being logged on one pool stream, which it's always the the pool configured on the first Winston Transport. But the log is never written on the second CloudWatch pool.

I am following this example: https://github.com/lazywithclass/winston-cloudwatch/blob/master/examples/multiple-loggers.js

lazywithclass commented 4 years ago

@bounteous hello and sorry for the delay.

Is this still an issue? If so, I'd need the steps to reproduce this, please confirm this would be a correct approach:

Thank you

Bounteous17 commented 4 years ago

Hello @lazywithclass , Yes, I build on that example. The problem is the intervals with which this module works. Lambdas are unable to identify that there are still jobs running in the background and the lambda is killed before writing to group B in cloudwatch.

The only solution I have found has been to use subscribers with a global variable.

Sorry I can not host the code, I don't own a personal AWS account.

lazywithclass commented 4 years ago

Ok I see.

Thanks for your reply; yes, setInterval has been a problem since the day after I coded this 5 years ago :D This issue will have to wait for #90 to be completed, which I'm working on right now, but it will take some time. The good news is that I might be able to also get rid of setInterval. Without setInterval I imagine this issue would be solved.