Closed jahirfiquitiva closed 6 years ago
See http://bumptech.github.io/glide/doc/configuration.html#application-options for how to setup Glide. During setup you can use setLogLevel
to reduce the verbosity of logs in Glide.
@sjudd
I only see Log.VERBOSE, Log.DEBUG, Log.INFO,Log.WARN, or Log.ERROR. Isn't there something like Log.NONE or something that could disable them completely?
@jahirfiquitiva Hello, I've reviewed some code in SingleRequest
:
private void onLoadFailed(GlideException e, int maxLogLevel) {
stateVerifier.throwIfRecycled();
int logLevel = glideContext.getLogLevel();
if (logLevel <= maxLogLevel) {
Log.w(GLIDE_TAG, "Load failed for " + model + " with size [" + width + "x" + height + "]", e);
if (logLevel <= Log.INFO) {
e.logRootCauses(GLIDE_TAG);
}
}
// other code omitted
}
In your case , if you only don't want to see those exceptions and causes, you can use setLevel() with Log.ERROR
, just as @sjudd says.
However, if you are searching for more advanced needs(e.g only exclude 404, or HttpException), maybe currently no solution except fork repo and custom your own Request
chain.
@Muyangmin Great. Thank you
Please add code to remove the logs
Please add code to remove the logs
Insert YourAppGlideModule class into your app)
import android.content.Context;
import android.util.Log;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;
@GlideModule
public class YourAppGlideModule extends AppGlideModule {
@Override
public void applyOptions(Context context, GlideBuilder builder) {
builder.setLogLevel(Log.ERROR);
}
}
Please add code to remove the logs
Insert YourAppGlideModule class into your app)
import android.content.Context; import android.util.Log; import com.bumptech.glide.GlideBuilder; import com.bumptech.glide.annotation.GlideModule; import com.bumptech.glide.module.AppGlideModule; @GlideModule public class YourAppGlideModule extends AppGlideModule { @Override public void applyOptions(Context context, GlideBuilder builder) { builder.setLogLevel(Log.ERROR); } }
ensure depencies is added in project build.gradle file
build.gradle
dependencies {
// Glide Component
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'com.github.bumptech.glide:annotations:4.11.0'
kapt 'com.github.bumptech.glide:compiler:4.11.0'
}
then remember to clean and rebuild your project to generate GlideApp class
V/ViewTarget: OnGlobalLayoutListener called attachStateListener=com.bumptech.glide.request.target.ViewTarget$SizeDeterminer$SizeDeterminerLayoutListener@a1f6740 V/ViewTarget: OnGlobalLayoutListener called attachStateListener=com.bumptech.glide.request.target.ViewTarget$SizeDeterminer$SizeDeterminerLayoutListener@ee8d88
I tried above mentioned points but still no no luck. Like above unnecessary Logs are printing..How to disable programatically?
use logcat filter Log Tag (regx) : ^(?!(Glide|EXCLUDE_TAG2)) package name : your app id
This worked for me
create glide module `@GlideModule public class YourAppGlideModule extends AppGlideModule {
@Override public void applyOptions(Context context, GlideBuilder builder) { builder.setLogLevel(Log.ERROR); } }`
ensure depencies is added in project build.gradle file as @bkhong87 stated `// Glide Component implementation 'com.github.bumptech.glide:glide:4.13.0' implementation 'com.github.bumptech.glide:annotations:4.13.0'
kapt 'com.github.bumptech.glide:compiler:4.13.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.13.0'`
Add the proguard config
-keep public class * extends com.bumptech.glide.module.AppGlideModule -keep class com.bumptech.glide.GeneratedAppGlideModuleImpl
voila!
Note: mine wasn't working since I made a Kotlin class module, so preprocessor wasn't using it
So you problably won't need both preprocessors
Also, to use kapt you require the plugin
id 'kotlin-android' id 'kotlin-kapt'
Saludos!
Glide Version: 4.1.1
Integration libraries: None
Device/Android Version: Genymotion Nexus 5X 7.1.1
Issue details / Repro steps / Use case background: I am getting a long log when trying to load a picture that does not exists. I know the easiest fix is to add an updated/working url, but sometimes I won't be able to do that really quick and I don't want the logs to show unnecessary stuff, so I want to disable them.
Stack trace / LogCat: