Timber(对Log类封装的一个工具)
2023-09-14 09:11:27 时间
Timber(对Log类封装的一个工具)
https://blog.csdn.net/hzl9966/article/details/51314137
https://www.jianshu.com/p/555c382a9d45
https://www.jianshu.com/p/39834be3cb6c
Timber只有一个类文件,可以单独把它复制出来放项目里,也可以通过Gradle引用:
compile 'com.jakewharton.timber:timber:2.7.1'
Timber使用的时候推荐在Application类中初始化,比如:
public class DemoApplication extends Application { @Override public void onCreate() { super.onCreate(); if (BuildConfig.DEBUG) { Timber.plant(new Timber.DebugTree()); } else { Timber.plant(new CrashReportingTree()); } } }
Timber.plant(Tree tree)用来给Timber设置用于打印的实现类,Tree是个接口,DebugTree是Timber中已经实现了tree的类,可直接拿来用。Timber中还有个HollowTree的类用于扩展,比如上面的CrashReportingTree,我们可以把崩溃打印进行一些处理。使用的时候调用静态方法即可:
Timber.tag("LifeCycles");//设置只能用一次的Tag Timber.d("Activity Created"); //DebugTree 会帮你进行格式化输出 Timber.i("A button with ID %s was clicked to say '%s'.", id, messag);
相关文章
- [Javascript] Advanced Console Log Arguments
- 执行RF测试只生成output.xml文件,不生成log和report文件
- EasyDarwin相关Android安卓客户端EasyPusher/EasyPlayer/EasyCamera/EasyClient在无开发环境进行log抓取
- svn update -r m path 代码还原到某个版本(这样之前的log日志也就没了,也就是清空log日志)
- 【RF库Collections测试】Log Dictionary 【同log list】
- No authorization to log on as a Trusted System L-RC=1 T-RC=0
- SAP Java GUI integration log
- Atitit 数据库与存储引擎设计与实现 attilax总结 1.1. 数据库的实现有很多种, 遵循一些理论规范,如 Fix Rules、Write-Ahead Log、Force-log-at-
- Android Studio 日志工具(5个级别Log)
- 华为部分真机调试无法显示log问题解决
- 008-log-slf4j+log4j
- 【好物推荐】IDEA插件推荐——MyBatis Log Plugin查看MyBatis实时输出的SQL脚本