How do I enable/disable log levels in Android?

后端 未结 18 2167
无人共我
无人共我 2020-11-22 16:42

I am having lots of logging statements to debug for example.

Log.v(TAG, \"Message here\");
Log.w(TAG, \" WARNING HERE\");

while deploying t

18条回答
  •  情深已故
    2020-11-22 17:20

    I took a simple route - creating a wrapper class that also makes use of variable parameter lists.

     public class Log{
            public static int LEVEL = android.util.Log.WARN;
    
    
        static public void d(String tag, String msgFormat, Object...args)
        {
            if (LEVEL<=android.util.Log.DEBUG)
            {
                android.util.Log.d(tag, String.format(msgFormat, args));
            }
        }
    
        static public void d(String tag, Throwable t, String msgFormat, Object...args)
        {
            if (LEVEL<=android.util.Log.DEBUG)
            {
                android.util.Log.d(tag, String.format(msgFormat, args), t);
            }
        }
    
        //...other level logging functions snipped
    

提交回复
热议问题