logger 打印工具使用

在使用这个工具的是,以为很简单,在使用的时候,取发现了问

官网:https://github.com/orhanobut/logger

按照官网的,

implementation 'com.orhanobut:logger:2.2.0'
Logger.addLogAdapter(new AndroidLogAdapter());

Setup

Download

implementation 'com.orhanobut:logger:2.2.0'

Initialize

Logger.addLogAdapter(new AndroidLogAdapter());

And use

Logger.d("hello");

正常,都是直接用  Logger.d("hello");  

但是在实际使用的时候,看见这样个问题

这第二个可变参数,怎么用,

找了很多资料,没看懂  最后问了写同事

String format arguments are supported

Logger.d("hello %s", "world");

(事后才明白,恍然大悟,)

官网有这句号:%s: 占位符:

Logger.e("hello %s", "worlod");
Logger.i("%s %s %s", "i ", "love ", "you");

占位符的作用,-----c中的打印都是这样的

最后:发现一个很坑的地方:就是有的手机 log.i()方法可以打印,有个log.d()不打印,,导致你在使用logger这个工具的时候,类似的方法也不打印。--------特别坑。

最后看了一下,这个博客

https://blog.csdn.net/chenqianleo/article/details/77655986

猜你喜欢

转载自blog.csdn.net/Andybfw/article/details/82720092