Skip to content

Commit

Permalink
Merge pull request #538 from alvasw/json_rpc_pretty_log
Browse files Browse the repository at this point in the history
JsonRpcClient: Pretty log full request and response
  • Loading branch information
alvasw authored Nov 4, 2022
2 parents fa1c773 + d05d8ef commit f54f70e
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@

import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.Moshi;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import okhttp3.logging.HttpLoggingInterceptor;

import java.io.IOException;
import java.util.Objects;

@Slf4j
public class JsonRpcClient {

public static final String AUTHORIZATION_HEADER_NAME = "Authorization";
Expand All @@ -40,8 +42,9 @@ public class JsonRpcClient {
public JsonRpcClient(JsonRpcEndpointSpec rpcEndpointSpec) {
this.rpcEndpointSpec = rpcEndpointSpec;

var loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
var loggingInterceptor = new HttpLoggingInterceptor(log::info);
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
loggingInterceptor.redactHeader(AUTHORIZATION_HEADER_NAME);

this.client = new OkHttpClient.Builder()
.addInterceptor(loggingInterceptor)
Expand Down

0 comments on commit f54f70e

Please sign in to comment.