Git Product home page Git Product logo

logrecorder's Introduction

LogRecorder

Record system or application log to sdcard on Android device.

Usage

直接复制 LogRecorder.java 文件到你的工程中,使用方式如下:
首先在AndroidManifest.xml中增加权限:

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

然后在代码中合适的地方使用,之后Log就会自动开始记录,直到调用logRecorder.stop(),或者进程结束:

	LogRecorder logRecorder
			 = new LogRecorder.Builder(context)
	               .setLogFolderName("foldername")
	               .setLogFolderPath("/sdcard/foldername")
	               .setLogFileNameSuffix("filesuffix")
	               .setLogFileSizeLimitation(256)
	               .setLogLevel(4)
	               .addLogFilterTag("ActivityManager")
	               .setPID(android.os.Process.myPid())
	               .build();

	logRecorder.start();

setLogFolderName()

设定log输出目录名,如果该值与folder path都没有设定的话,会默认使用应用包名在sdcard下新建目录。

setLogFolderPath()

设置Log输出目录绝对路径,该值会优先使用,会忽略folder name的设置。

setLogFileNameSuffix()

log文件名前缀,文件名会使用时间的形式,该值的设定会自动追加在时间之前,如setLogFileNameSuffix("mylog") 则最后的文件名为mylog-2016-02-04-12-26-53.log

setLogFileSizeLimitation()

单个log文件的大小限制,超过设置的限制时,会自动新起新的文件记录log,注意: 是以KB为单位的。

setLogLevel()

设置记录的log级别,默认2
2 = verbose
3 = debug
4 = info
5 = warning
6 = error
7 = silent(不输出任何log)

addLogFilterTag()

设置log过滤的tag,可以add多个,如addLogFilterTag("ActivityManager")表示只过滤“ActivityManager”的log

setPID()

通过该方法可以指定一个特定的进程的log,如通过setPID(android.os.Process.myPid()) 即可只输出自己的APP的log。

logrecorder's People

Contributors

dxjia avatar

Stargazers

 avatar JorgeLiang avatar ggband avatar  avatar  avatar  avatar  avatar  avatar Jingle avatar Eric avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.