Closed
Description
Use case
I want the incoming log event to be automatically logged for me when POWERTOOLS_LOGGER_LOG_EVENT
is set to true and I'm not using middy or a handler class. Middy and handler class usage is demonstrated in docs here.
Solution/User Experience
Conditionally log incoming event based on POWERTOOLS_LOGGER_LOG_EVENT
within Logger.addContext. I know this may seem strange to put "log incoming event logic" into the addContext
method, but that's how it's implemented with middy (injectLambdaContext
) and class decorator (logger.injectLambdaContext
).
With this solution, the below function would log incoming event. Currently it does not.
import { Logger } from "@aws-lambda-powertools/logger";
process.env.POWERTOOLS_LOGGER_LOG_EVENT = "true";
const logger = new Logger();
export function handler(event, context) {
logger.addContext(context);
// do work
}
Alternative solutions
No response
Acknowledgment
- This feature request meets Powertools for AWS Lambda (TypeScript) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Shipped