Android开源日志库Logger

开源地址:https://github.com/orhanobut/logger

参考

1.http://www.open-open.com/lib/view/open1427166371418.html

2.http://www.jianshu.com/p/21902079e88f

日志程序提供了 : 

  • 线程信息Thread information 
  • 类信息Class information 
  • 方法信息Method information 
  • 漂亮打印的JSON内容Pretty-print for json content 
  • Clean output 
  • Jump to source feature

Gradle 

compile 'com.orhanobut:logger:1.3'

当前的Log 系统

Log.d(TAG,"hello");

Logger 

Logger.d("hello");

用法 

Logger.d("hello");
Logger.e("hello");
Logger.w("hello");
Logger.v("hello");
Logger.wtf("hello");
Logger.json(JSON_CONTENT);

如下:

默认打印的TAG是PRETTYLOGGER,这个是Logger默认的tag,如果要修改可以:

// 修改打印的tag值
Logger.init("MainActivity");
String userName = "Jerry";
Logger.i(userName);

有的小伙伴觉得,我不想一直都只用一个tag,那岂不是要写很多的Logger.init(tag)来修改,我们看方法名叫init,作者的意思估计是只用一次就好了。

可设置为:

Settings (optional)
Change the settings with init. This should be called only once. Best place would be in application class. All of them are optional.
Logger
   .init(YOUR_TAG)               // default tag : PRETTYLOGGER or use just init()
   .setMethodCount(3)            // default 2
   .hideThreadInfo()             // default it is shown
   .setLogLevel(LogLevel.NONE);  // default : LogLevel.FULL

 

posted @ 2017-04-03 00:18  ryan_ys  阅读(3184)  评论(0编辑  收藏  举报