generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 98
Open
Labels
Description
Use case
The Logging utility currently only offers a benefit to developers when used with the AspectJ @Logging
annotation. The purpose of this feature request is to add a functional interface to initialize the Logging utility similar to TracingUtils
.
Solution/User Experience
We can re-use the existing PowertoolsLogging
facade that abstracts away the logging backend for certain Powertools specific features such as Log buffering.
Example
Usage with AspectJ
public class App implements RequestHandler<APIGatewayProxyRequestEvent, String> {
private static final Logger log = LoggerFactory.getLogger(App.class);
@Logging(logEvent = true, logResponse = true, samplingRate = 0.7, correlationIdPath = "requestContext.requestId")
public String handleRequest(APIGatewayProxyRequestEvent input, Context context) {
log.info("Processing request");
return "Hello World";
}
}
Usage without AspectJ
public class App implements RequestHandler<APIGatewayProxyRequestEvent, String> {
private static final Logger log = LoggerFactory.getLogger(App.class);
public String handleRequest(APIGatewayProxyRequestEvent input, Context context) {
PowertoolsLogging.initializeLogging(context, 0.7, "requestContext.requestId", input);
// Manual event logging (if desired)
log.info("Handler Event", entry("event", input));
log.info("Processing request");
String response = "Hello World";
// Manual response logging (if desired)
log.info("Handler Response", entry("response", response));
return response;
}
}
Alternative solutions
Acknowledgment
- This feature request meets Powertools for AWS Lambda (Java) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, TypeScript, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Working on it