Skip to content

Feature request: Simplified logger formatter when in AWS SAM Local #1527

Closed
@pmarko1711

Description

@pmarko1711

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions