framework中的Log如何打印出来

编程入门 行业动态 更新时间:2024-10-26 17:22:49

framework中的Log如何<a href=https://www.elefans.com/category/jswz/34/1728197.html style=打印出来"/>

framework中的Log如何打印出来

在从事framework开发的过程中,经常会看到如下代码

public class AudioService extends IAudioService.Stubimplements AccessibilityManager.TouchExplorationStateChangeListener,AccessibilityManager.AccessibilityServicesStateChangeListener {private static final String TAG = "AudioService";/** Debug audio mode */protected static final boolean DEBUG_MODE = Log.isLoggable(TAG + ".MOD", Log.DEBUG);/** Debug audio policy feature */protected static final boolean DEBUG_AP = Log.isLoggable(TAG + ".AP", Log.DEBUG);/** Debug volumes */protected static final boolean DEBUG_VOL = Log.isLoggable(TAG + ".VOL", Log.DEBUG);/** debug calls to devices APIs */protected static final boolean DEBUG_DEVICES = Log.isLoggable(TAG + ".DEVICES", Log.DEBUG);
}

这些Log默认都是关闭的,想要打开其实也很容易

    /*** 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.&lt;YOUR_LOG_TAG> &lt;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.&lt;YOUR_LOG_TAG>=&lt;LEVEL>'*  and place that in /data/local.prop.** @param tag The tag to check.* @param level The level to check.* @return Whether or not that this is allowed to be logged.* @throws IllegalArgumentException is thrown if the tag.length() > 23*         for Nougat (7.0) releases (API <= 23) and prior, there is no*         tag limit of concern after this API level.*/public static native boolean isLoggable(String tag, int level);

第一种方法:

setprop log.tag.AudioService.VOL D
stop
start

第二种方法:

这种方法重启以后他的系统属性也会保留,因为重启以后打开还是会打开

setprop persist.log.tag.AudioService.VOL D

更多推荐

framework中的Log如何打印出来

本文发布于:2024-03-13 04:04:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1733148.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:打印出来   framework   Log

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!