3
可能是一個新手問題,但我想知道我在哪裏實際上捕捉日誌貓的日誌。有沒有我把日誌,一個特殊的正則表達式來使用等,這是我的攔截器是什麼樣子的特定位置:Retrofit2 HttpLoggingInterceptor Logcat
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient okClient = new OkHttpClient.Builder().addInterceptor(interceptor).build();
// Retrofit setup
Retrofit client = new retrofit2.Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.client(okClient)
.build();
這裏是一個API調用在身體是空
retrofit2.Call<GeneralTokenResponse> generalTokenResponseCall = ApiInterface.getGeneralAccessToken(ApiGeneral.API_VERSION);
generalTokenResponseCall.enqueue(new retrofit2.Callback<GeneralTokenResponse>() {
@Override
public void onResponse(retrofit2.Call<GeneralTokenResponse> call, retrofit2.Response<GeneralTokenResponse> response) {
Log.d("DEBUG", "body: "+response.body());
}
@Override
public void onFailure(retrofit2.Call<GeneralTokenResponse> call, Throwable t) {
}
});