openpix / logutils

Android logutils tools

Home Page:https://github.com/openpix/logutils

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

openpix/logutils

logutils

这个库是用来封装android日志打印的库。主要封装了安装的Log类。

主要功能是方便日志打印,将日志写入到文件中。

1.引用

appbuild.gradle中加入引用

    implementation 'com.openpix:logutils:1.0.0'

AndroidManifest.xml中加入权限

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

2.日志文件存储路径

默认的存储路径是/mnt/sdcard/openpix/log/yyyy-MM-dd.txt

设置日志文件路径

    LogUtils.setFileLogPath(xxxx);

日志文件存储路径 xxxx/yyyy-MM-dd.txt

3.常用用法

日志方法默认采用调用的类名作为日志的TAG,并且打印调用的行号及方法名。

LogUtils.d()

这种一般加载方法的第一行,或者最后一行。

LogUtils.d("msgId:" + msgId);

带参数的输出。

4.日志的打开与关闭

LogUtils类中定义了两个静态变量,用来控制是否输出日志,是否在LogCat中输出 <++>

  • 默认:LogUtils.ISDEBUG=true; and LogUtils.ISLOGCAT=true;: 输出日志到文件中,并且在LogCat中输出
  • LogUtils.ISDEBUG=true; and LogUtils.ISLOGCAT=false;:日志写文件,但是不会在LogCat中输出
  • LogUtils.ISDEBUG=false;:关闭日志,既不输出到文件,也不输出到LogCat中。

About

Android logutils tools

https://github.com/openpix/logutils


Languages

Language:Java 88.9%Language:Kotlin 11.1%