同样的方法——但使用一个Timber
类而不是Log
——行不通吗?例如:
-assumenosideeffects class timber.log.Timber* {
public static *** v(...);
public static *** d(...);
public static *** i(...);
}
或者,您可以按照示例项目执行以下操作:
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
if (BuildConfig.DEBUG) {
Timber.plant(new DebugTree());
} else {
Timber.plant(new ProductionTree());
}
}
private static class ProductionTree extends Timber.Tree {
@Override
protected void log(int priority, String tag, String message, Throwable t) {
// Do whatever (or nothing) here.
}
}
}