fix up logging problem

This commit is contained in:
Grahame Grieve 2022-01-13 17:38:39 +11:00
parent 758c2ebe7b
commit 554a458b57
3 changed files with 35 additions and 6 deletions

View File

@ -26,8 +26,17 @@ public class FhirLoggingInterceptor implements Interceptor {
public Response intercept(@Nonnull Interceptor.Chain chain) throws IOException {
// Log Request
Request request = chain.request();
logger.logRequest(request.method(), request.url().toString(), new ArrayList<>(request.headers().names()),
request.body() != null ? request.body().toString().getBytes() : null);
List<String> hdrs = new ArrayList<>();
for (String s : request.headers().toString().split("\\n")) {
hdrs.add(s.trim());
}
byte[] cnt = null;
if (request.body() != null) {
Buffer buf = new Buffer();
request.body().writeTo(buf);
cnt = buf.readByteArray();
}
logger.logRequest(request.method(), request.url().toString(), hdrs, cnt);
// Log Response
Response response = null;

View File

@ -26,8 +26,17 @@ public class FhirLoggingInterceptor implements Interceptor {
public Response intercept(@Nonnull Interceptor.Chain chain) throws IOException {
// Log Request
Request request = chain.request();
logger.logRequest(request.method(), request.url().toString(), new ArrayList<>(request.headers().names()),
request.body() != null ? request.body().toString().getBytes() : null);
List<String> hdrs = new ArrayList<>();
for (String s : request.headers().toString().split("\\n")) {
hdrs.add(s.trim());
}
byte[] cnt = null;
if (request.body() != null) {
Buffer buf = new Buffer();
request.body().writeTo(buf);
cnt = buf.readByteArray();
}
logger.logRequest(request.method(), request.url().toString(), hdrs, cnt);
// Log Response
Response response = null;

View File

@ -1,6 +1,8 @@
package org.hl7.fhir.r5.utils.client.network;
import okhttp3.*;
import okio.Buffer;
import org.hl7.fhir.utilities.ToolingClientLogger;
import javax.annotation.Nonnull;
@ -26,8 +28,17 @@ public class FhirLoggingInterceptor implements Interceptor {
public Response intercept(@Nonnull Interceptor.Chain chain) throws IOException {
// Log Request
Request request = chain.request();
logger.logRequest(request.method(), request.url().toString(), new ArrayList<>(request.headers().names()),
request.body() != null ? request.body().toString().getBytes() : null);
List<String> hdrs = new ArrayList<>();
for (String s : request.headers().toString().split("\\n")) {
hdrs.add(s.trim());
}
byte[] cnt = null;
if (request.body() != null) {
Buffer buf = new Buffer();
request.body().writeTo(buf);
cnt = buf.readByteArray();
}
logger.logRequest(request.method(), request.url().toString(), hdrs, cnt);
// Log Response
Response response = null;