@Override
  public Response call(Request req) {

    if (!logger.isDebugEnabled()) {
      return delegate.call(req);
    }

    logger
        .atDebug()
        .addKeyValue("url", () -> req.uri().toString())
        .addKeyValue(
            "headers",
            () ->
                req.headers().stream()
                    .map(h -> h.name() + ": " + h.value())
                    .collect(Collectors.joining("\n")))
        .addKeyValue("method", req::method)
        .addKeyValue(
            "body", () -> req.body() != null ? new String(req.body(), StandardCharsets.UTF_8) : "")
        .log("request: %s %s".formatted(req.method(), req.uri()));

    var res = delegate.call(req);

    logger
        .atDebug()
        .addKeyValue("url", () -> req.uri().toString())
        .addKeyValue("status", () -> Integer.toString(res.status()))
        .addKeyValue(
            "headers",
            () ->
                res.headers().stream()
                    .map(h -> h.name() + ": " + h.value())
                    .collect(Collectors.joining("\n")))
        .addKeyValue("method", req::method)
        .addKeyValue(
            "body", () -> res.body() != null ? new String(res.body(), StandardCharsets.UTF_8) : "")
        .log("response: %s %s %d".formatted(req.method(), req.uri(), res.status()));

    return res;
  }
@Test
  void logCall() {

    var body = "Hello World!";
    var res =
        new HttpClient.Response(
            200,
            List.of(new HttpClient.Header("content-type", "text/plain")),
            body.getBytes(StandardCharsets.UTF_8));

    var delegate = mock(HttpClient.class);
    when(delegate.call(any())).thenReturn(res);

    var sut = new LoggingHttpClient(delegate);

    logger.setLevel(Level.DEBUG);

    // when
    sut.call(
        new HttpClient.Request(URI.create("http://localhost:1234/test"), "GET", List.of(), null));

    // then
    assertEquals(2, logs.list.size());

    var requestLog = logs.list.get(0);
    var responseLog = logs.list.get(1);

    assertRequestLog(requestLog);
    assertResponseLog(responseLog, res);
  }