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
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Use case
The Logging utility currently only offers a benefit to developers when used with the AspectJ
@Loggingannotation. The purpose of this feature request is to add a functional interface to initialize the Logging utility similar toTracingUtils.Solution/User Experience
We can re-use the existing
PowertoolsLoggingfacade that abstracts away the logging backend for certain Powertools specific features such as Log buffering.Example
Usage with AspectJ
Usage without AspectJ
Alternative solutions
Acknowledgment
Future readers
Please react with 👍 and your use case to help us understand customer demand.