打印出来"/>
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.<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.** @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如何打印出来
发布评论