滑行:记录每个请求 [英] Glide: log each request

查看:91
本文介绍了滑行:记录每个请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑以下代码:

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),如:

要查看Glide的内部引擎如何以及何时找到所需资源,可以启用日志记录:

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

这将提示以下输出:

如果您对其他日志不感兴趣,则只能启用Engine日志记录.

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

这篇关于滑行:记录每个请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆