zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    关于tinymce编辑器插件重新初始化问题
    16进制=>rebg(包含透明度的转换处理)
    在vue项目中所有地方拿到当前项目的vue实例
    vue-draggable两种情况下的demo
    Docker管理工具之portainer
    SpringBoot集成Elasticsearch
    ElasticSearch添加索引
    Docker安装ElasticSearch
    RabbitMQ学习总结(2)-API的使用
    Docker安装RabbitMQ
  • 原文地址:https://www.cnblogs.com/ryan-ys/p/6660354.html
Copyright © 2011-2022 走看看