Skip to content

Commit

Permalink
fix: rest log interceptor logger name inject
Browse files Browse the repository at this point in the history
  • Loading branch information
andrejpetras committed Jun 11, 2024
1 parent 4d226b0 commit 4d07e12
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/modules/tkit-quarkus/pages/includes/attributes.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:project-version: 2.23.0
:project-version: 2.24.0
:quarkus-version: 3.11.1

:examples-dir: ./../examples/
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class RestInterceptorContext {

boolean exclude = false;

String logger;

Set<String> mdcKeys = new HashSet<>();

private final long startTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public void filter(ContainerRequestContext requestContext) {
});
}

restContext.ano = RestRecorder.getRestService(resourceInfo.getResourceClass().getName(),
restContext.logger = resourceInfo.getResourceClass().getName();
restContext.ano = RestRecorder.getRestService(restContext.logger,
resourceInfo.getResourceMethod().getName());

UriInfo uriInfo = requestContext.getUriInfo();
Expand All @@ -75,7 +76,7 @@ public void filter(ContainerRequestContext requestContext) {
log = restContext.ano.config.log;
}
if (config.start.enabled && log) {
LoggerFactory.getLogger(resourceInfo.getResourceClass())
LoggerFactory.getLogger(restContext.logger)
.info(String.format(config.start.template, restContext.method, restContext.path, restContext.uri));
}
requestContext.setProperty(CONTEXT, restContext);
Expand Down Expand Up @@ -131,7 +132,7 @@ public void filter(ContainerRequestContext requestContext, ContainerResponseCont
restContext.mdcKeys.add(config.end.mdc.responseStatusName);
}

LoggerFactory.getLogger(resourceInfo.getResourceClass())
LoggerFactory.getLogger(restContext.logger)
.info(String.format(config.end.template, restContext.method, restContext.path,
restContext.durationString, status.getStatusCode(), status.getReasonPhrase(),
restContext.uri));
Expand Down

0 comments on commit 4d07e12

Please sign in to comment.