Glide: log each request

Consider the code below:

Glide.with(<your_context>)
    .load(<remote_file_url, local_file_path>)
    .into(<imageview>);

The code above Glide is written in many files. I just want to register my remote_file_url or local_file_path in logcat. But I do not want to change the code in each file.

Is Glide logging permissible? If enabled, then I need a simple central way to enable sliding logging.

For reference: I want a way how Retrofit + okhttpto resolve. As OkHttpI just need to add an interceptor in one place, and it will record information about each call webservice without having to write another line of code.

+6
source share
1 answer

In Glide 4.0 RC , which is possible through Glide Configuration : you can configure the level of logging Glidethrough 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 can see the following registration console:

enter image description here


For older versions ( 3.x), as indicated in the Debugging Workflow :

To find out how and when the internal Glide engine finds the required resources, 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

The following message will appear:

enter image description here

You can only enable logging Engineif you are not interested in other logs.

+6
source

All Articles