Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Glide: log each request

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.

like image 583
Moinkhan Avatar asked Jun 17 '17 07:06

Moinkhan


1 Answers

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:

enter image description here


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:

enter image description here

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

like image 140
azizbekian Avatar answered Oct 09 '22 18:10

azizbekian