Closed
Description
Use case
I use aws_lambda_powertools.Logger
which works very nicely when looking at logs in Cloudwatch.
Nevertheless, when testing/debugging lambda functions using AWS SAM local invoke, I find the json representation difficult to read and cluttering the console too much.
I know I can swap the logger, or use a custom formatter. But would it not be meaningful to include a simple formatter (instead of the LambdaPowertoolsFormatter
that prints out jsons) and use it automatically when not really in Lambda (but e.g. in AWS SAM local invoke) ?
Related issue: #409
Note:
- Strictly speaking this request might breach your tenet 1 ("AWS Lambda only"), but it depends where you place AWS SAM local invoke or development & testing of Lambda functions outside Lambda
Solution/User Experience
- Add a "simple" formatter that would print a single line, without serializing to json
- optionally with a custom format
- With that, use the existing json formatter only when really in Lambda
- or alternatively, use the simple one when in AWS SAM Local (and similar, if it can be detected).
- or make it easy to swap, by e.g. an envvar
Alternative solutions
There exists a solution already and that is to use a custom formatter.
I opened the issue to consider building this in thinking that it might be beneficial for more users developing and testing Lambda functions.
Acknowledgment
- This feature request meets Lambda Powertools Tenets
- Should this be considered in other Lambda Powertools languages? i.e. Java, TypeScript