android log.d 格式化,android – 在我的代码中使用Log.d()或Log.e()
考慮使用它:
isLoggable()
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. 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.= and place that in /data/local.prop
就個人而言,我會刪除調試日志并使用Proguard保留錯誤日志.
最好像這樣包裝它:
public class MyLog {
public static void d(String tag,String msg) {
if (Log.isLoggable(tag,Log.DEBUG)) {
Log.d(tag,msg);
}
}
public static void i(String tag,String msg) {
if (Log.isLoggable(tag,Log.INFO)) {
Log.i(tag,msg);
}
} // and so on...
總結
以上是生活随笔為你收集整理的android log.d 格式化,android – 在我的代码中使用Log.d()或Log.e()的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android启动过程五个步骤,Andr
- 下一篇: Android封装快捷键,android