【发布时间】:2018-03-02 14:06:21
【问题描述】:
我正在尝试清除日志中的垃圾,例如
*�$ʞx���J/
当我收到图片时
所以我尝试覆盖 HttpLoggingInterceptor intercept(),以检测是否有 Content-Type => image/jpeg 标头作为响应,但 HttpLoggingInterceptor 是最终的,所以我无法扩展它:(
RetrofitModule 中的代码:
OkHttpClient provideOkHttpClient(Context context, Application app, Preferences preferences) {
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(BuildConfig.DEBUG ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.HEADERS);
Cache cache = new Cache(app.getCacheDir(), cacheSize);
return new OkHttpClient.Builder()
.addNetworkInterceptor(new OkHttpInterceptor(context, preferences))
.addInterceptor(loggingInterceptor)
.cache(cache)
.build();
}
如何在我的项目中禁用图像记录?
【问题讨论】:
-
不敢相信所有很酷的开发人员都忽略了日志中的垃圾:(
标签: android kotlin logging retrofit okhttp