Skip to content

Commit 74094fb

Browse files
committed
Minor format
1 parent ebcb1bd commit 74094fb

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

core/src/main/java/com/sap/ai/sdk/core/common/ClientResponseHandler.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,14 @@ private static String getErrorMessage(
174174
}
175175

176176
private static void logResponseSuccess(final @Nonnull ClassicHttpResponse response) {
177-
val duration =
178-
Optional.ofNullable(response.getFirstHeader("x-upstream-service-time"))
179-
.map(h -> h.getValue() + "ms")
180-
.orElseGet(() -> "unknown");
177+
if (!log.isDebugEnabled()) {
178+
return;
179+
}
180+
val headerTime = Optional.ofNullable(response.getFirstHeader("x-upstream-service-time"));
181+
val duration = headerTime.map(h -> h.getValue() + "ms").orElseGet(() -> "unknown");
181182
val entityLength = response.getEntity().getContentLength();
182183
val sizeInfo = entityLength >= 0 ? String.format("%.1fKB", entityLength / 1024.0) : "unknown";
183-
log.debug(
184-
"[reqId={}] {} request completed successfully with duration={}, size={}.",
185-
MDC.get("reqId"),
186-
MDC.get("service"),
187-
duration,
188-
sizeInfo);
184+
val msg = "[reqId={}] {} request completed successfully with duration={}, size={}.";
185+
log.debug(msg, MDC.get("reqId"), MDC.get("service"), duration, sizeInfo);
189186
}
190187
}

0 commit comments

Comments
 (0)