我有很多的日志记录语句到调试的例子。
I am having lots of logging statements to debug for example.
Log.v(TAG, "Message here");
Log.w(TAG, " WARNING HERE");
在部署设备上的电话本应用程序,我想关掉从那里我可以启用/禁用记录了详细的日志记录。
while deploying this application on device phone i want to turn off the verbose logging from where i can enable/disable logging.
一个常见的方式是让一个int名为日志级别,其调试级别基于日志级别定义。
A common way is to make an int named loglevel, and define its debug level based on loglevel.
public static int LOGLEVEL = 2;
public static boolean ERROR = LOGLEVEL > 0;
public static boolean WARN = LOGLEVEL > 1;
...
public static boolean VERBOSE = LOGLEVEL > 4;
if (VERBOSE) Log.v(TAG, "Message here"); // Won't be shown
if (WARN) Log.w(TAG, "WARNING HERE"); // Still goes through
之后,你可以改变的LOGLEVEL所有调试输出电平。
Later, you can just change the LOGLEVEL for all debug output level.
上一篇:获得使用亚马逊的API产品的详细信息亚马逊、详细信息、产品、API
下一篇:我如何从一个preferenceActivity在Android上的共享preferences?preferenceActivity、Android、preferences