问题描述
考虑以下代码:
Glide.with(<your_context>)
.load(<remote_file_url, local_file_path>)
.into(<imageview>);
上面的Glide代码写在很多文件中.我只想在logcat中记录我的 remote_file_url 或 local_file_path .但是我不想更改每个文件中的代码.
Above Glide code is written in lots of file.Simply I want to log my remote_file_url or local_file_path in logcat. But I don't want to change the code in every file.
Glide是否允许记录?如果允许的话,那么我需要一种简单的集中方式来启用滑行记录.
Is Glide allowing logging? If it allows, then I need a simple central way to turn on glide logging.
供参考:我希望像Retrofit + okhttp
这样的方式允许.在OkHttp
中,我只需要在一个位置添加拦截器,它就可以记录有关每个Web服务调用的信息,而无需编写其他任何代码.
For Reference: I want the way like Retrofit + okhttp
allow. In OkHttp
, I just have to add interceptor at one location and it will log information about each webservice call without writing any other additional code.
推荐答案
在 Glide 4.0 RC 可以通过 Glide配置进行:可以通过Glide的日志记录级别"rel =" noreferrer> GlideBuilder#setLogLevel(int)
.
In Glide 4.0 RC that's possible via Glide configuration: you can configure Glide
's logging level via GlideBuilder#setLogLevel(int)
.
具有MyGlideModule.java
:
@GlideModule
public class MyGlideModule extends AppGlideModule {
@Override
public void applyOptions(Context context, GlideBuilder builder) {
builder.setLogLevel(Log.VERBOSE);
}
}
然后您将能够在控制台中看到以下日志:
Then you'll be able to see following log in console:
对于旧版本(3.x
),如调试工作流程" :
adb shell setprop log.tag.Engine VERBOSE
adb shell setprop log.tag.EngineJob VERBOSE
adb shell setprop log.tag.DecodeJob VERBOSE
这将提示以下输出:
如果您对其他日志不感兴趣,则只能启用Engine
日志记录.
You can enable only Engine
logging if you are not interested in other logs.
这篇关于滑行:记录每个请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!