问题
Consider the code below:
Glide.with(<your_context>)
.load(<remote_file_url, local_file_path>)
.into(<imageview>);
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.
Is Glide allowing logging? If it allows, then I need a simple central way to turn on glide logging.
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.
回答1:
In Glide 4.0 RC that's possible via Glide configuration: you can configure Glide
's logging level via GlideBuilder#setLogLevel(int).
Having 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:
For older versions (3.x
), as mentioned in "Debugging workflow":
To view how and when Glide's internal engine finds the resources you asked for, you can enable logging:
adb shell setprop log.tag.Engine VERBOSE
adb shell setprop log.tag.EngineJob VERBOSE
adb shell setprop log.tag.DecodeJob VERBOSE
This will prompt with following output:
You can enable only Engine
logging if you are not interested in other logs.
来源:https://stackoverflow.com/questions/44602131/glide-log-each-request