首页 > 移动平台 > 详细

Android开源日志库Logger

时间:2017-04-03 01:12:32      阅读:190      评论:0      收藏:0      [点我收藏+]

开源地址: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

 

Android开源日志库Logger

原文:http://www.cnblogs.com/ryan-ys/p/6660354.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!