getndazn / dazn-lambda-powertools

Powertools (logger, HTTP client, AWS clients, middlewares, patterns) for Lambda functions.
https://getndazn.github.io/dazn-lambda-powertools
MIT License
740 stars 77 forks source link

Middleware-sample-logging to have a switch not to print uncaught errors #145

Closed lkhari closed 4 years ago

lkhari commented 4 years ago

This is a Feature Proposal

Description

Similar or dependent issues:

theburningmonk commented 4 years ago

@lkhari while I think it's a good option to have, I don't understand why you wouldn't want an error log message in the case of Step Functions and AppSync resolver functions. Can you clarify?

lkhari commented 4 years ago

An example is, on the site i'm working we have very little frontend validation. So often the requests come to the backend through appsync and aren't suited due to incorrect dates etc. I can't return the message back through graphql since it's expecting a specific entity, so I throw a validation error.

I use error logging as more high priority issues which require fixing urgently, which these validation errors are often not an issue so i log them as warnings.

That's my reason, but I can also see people wanting to be able to format the message diffferently like in issue #98

Note: if you have a better way of returning validation errors, i'm happy to hear.

theburningmonk commented 4 years ago

mm.. I see, the problem here is that when something does go wrong (not related to validation) then you also won't have those error log messages, which captures the invocation event, etc.

98 is a different case, the core problem (here) is that they have a specific logging convention so want to override the log message itself & also increment a custom metric, something that they'd be able to do easily with a custom logger.

lkhari commented 4 years ago

Yea, that is true. I think, to be honest, if you have made the decision to turn off the error catching in this package, then you most likely going to understand that you must handle errors in your code.

theburningmonk commented 4 years ago

fixed by #146