您的位置:首页 > 移动开发 > Android开发

Android Log 工具类支持输出调用代码所属的线程ID,文件名,行号,方法名

2011-09-27 18:03 501 查看

代码

gist1244723

特性

1. 支持输出调用代码所属的线程ID,文件名,行号,方法名

09-27 17:38:45.311 D/SIPUA   ( 4700): [ Thread-132: Sipdroid.java: 410: run() ] _____ -----> PT=103, SSRC=0xbb7431a6, Seq= 268, len=1414, plen=1402, ts=1938987090


2. 支持动态设置日志输出级别,原理参考

public static boolean isLoggable (String tag, int level)

Since: API Level 1

Checks to see whether or not a log for the specified tag is loggable at the specified level. The default level of any tag is set to INFO. This means that any level above and including INFO will be logged. Before you make any calls to a logging method you should check to see if your tag should be logged. You can change the default level by setting a system property: 'setprop log.tag.<YOUR_LOG_TAG> <LEVEL>' Where level is either VERBOSE, DEBUG, INFO, WARN, ERROR, ASSERT, or SUPPRESS. SUPPRESS will turn off all logging for your tag. You can also create a local.prop file that with the following in it: 'log.tag.<YOUR_LOG_TAG>=<LEVEL>' and place that in /data/local.prop.

Parameters
tagThe tag to check.
levelThe level to check.
Returns

Whether or not that this is allowed to be logged.

Throws
IllegalArgumentExceptionis thrown if the tag.length() > 23.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐