Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hexoul committed May 14, 2021
1 parent f4de651 commit ae031ce
Showing 1 changed file with 11 additions and 12 deletions.
Expand Up @@ -52,22 +52,21 @@ public static void logWhenComplete(
Logger logger, RequestContext ctx,
Consumer<RequestOnlyLog> requestLogger, Consumer<RequestLog> responseLogger) {
final boolean isTransientService = isTransientService(ctx);
final CompletableFuture<RequestOnlyLog> requestCompletionFuture = ctx.log().whenRequestComplete();
final CompletableFuture<RequestOnlyLog> requestCompletionFuture;
if (!isTransientService) {
requestCompletionFuture.thenAccept(requestLogger).exceptionally(e -> {
try (SafeCloseable ignored = ctx.push()) {
logger.warn("{} Unexpected exception while logging request: ", ctx, e);
}
return null;
requestCompletionFuture = ctx.log().whenRequestComplete().thenApply(log -> {
requestLogger.accept(log);
return log;
});
} else {
requestCompletionFuture.exceptionally(e -> {
try (SafeCloseable ignored = ctx.push()) {
logger.warn("{} Unexpected exception while logging request: ", ctx, e);
}
return null;
});
requestCompletionFuture = ctx.log().whenRequestComplete();
}
requestCompletionFuture.exceptionally(e -> {
try (SafeCloseable ignored = ctx.push()) {
logger.warn("{} Unexpected exception while logging request: ", ctx, e);
}
return null;
});
ctx.log().whenComplete().thenAccept(responseLogger).exceptionally(e -> {
try (SafeCloseable ignored = ctx.push()) {
logger.warn("{} Unexpected exception while logging response: ", ctx, e);
Expand Down

0 comments on commit ae031ce

Please sign in to comment.