bunyan-cloudwatch icon indicating copy to clipboard operation
bunyan-cloudwatch copied to clipboard

Logging error handling

Open santiagoaguiar opened this issue 9 years ago • 3 comments

It seems that now to handle errors during logging we need to define an onError function for the stream object.

IMO, it should provide a default onError function that swallow errors, since logging should never make your application to crash, which is the current behavior if you haven't defined this function.

Also, maybe since the stream inherits from Writeable, error handling should be performed by using a stream.on('error', function(err) {...}) instead of using this onError function. Or otherwise, we could pass the error function as part of the options. It doesn't feel right to have to define that function directly over the stream.

Opinions?

santiagoaguiar avatar Aug 03 '15 21:08 santiagoaguiar

+1 on using stream.on('error', (err) => {...})

README.md states this is a Writable stream, so this module should implement that interface instead of defining its own. Additionally onError is not documented in the README.md.

jerroydmoore avatar Mar 14 '17 16:03 jerroydmoore

I just got a crash for lack of connectivity too. Logging should not kill servers.

ubershmekel avatar Jun 13 '18 17:06 ubershmekel

This just happened to us as well when we hit a ThrottlingException. We ended up needing to wrap the logging calls in a domain to avoid the error from blowing up the Express web server. There needs to be a documented best practice and examples on how to handled these types of errors.

shawnbissell avatar Feb 15 '19 21:02 shawnbissell