Android開源日誌庫Logger

開源地址:https://github.com/orhanobut/loggerhtml

參考git

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

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

日誌程序提供了 : app

  • 線程信息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);

以下:ide

默認打印的TAG是PRETTYLOGGER,這個是Logger默認的tag,若是要修改能夠:spa

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

有的小夥伴以爲,我不想一直都只用一個tag,那豈不是要寫不少的Logger.init(tag)來修改,咱們看方法名叫init,做者的意思估計是隻用一次就行了。線程

可設置爲:3d

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
相關文章
相關標籤/搜索