Skip to content

Feature request: Logger - ability to clear state #2337

Closed
@rcoundon

Description

@rcoundon

Use case

Hi - we're beginning to use Powertools Logger as a canonical logger. By that I mean we append various key/values to the logger as the lambda executes and then flush them to stdout by calling a write method e.g myLogger.info('canonical');

Chatting with @am29d and @dreamorosi on Discord, it was confirmed there's no way to clear the keys that were added using appendKeys(). This means that those keys remain present during the next warm lambda invocation.

Solution/User Experience

Providing a logger method such as clearState() that clears down any user appended keys would solve the problem.

Alternative solutions

The only other solution in user land is to keep track of the appended keys and clear them down using removeKeys

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Metadata

Metadata

Assignees

Labels

completedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilityloggerThis item relates to the Logger Utility

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions