Logx.java
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Logx.java相关的知识,希望对你有一定的参考价值。
1 import android.util.Log; 2 import android.widget.Toast; 3 4 public class Logx { 5 private static final String TAG = "(Logx)"; 6 private String className = ""; 7 8 public Logx (Class<?> cls) { 9 className = "\t\t [ " + cls.getSimpleName() + " ] "; 10 } 11 12 public void e (String text) { Log.e(TAG, getMessage(text)); } 13 public void w (String text) { Log.w(TAG, getMessage(text)); } 14 public void i (String text) { Log.i(TAG, getMessage(text)); } 15 public void d (String text) { Log.d(TAG, getMessage(text)); } 16 public void v (String text) { Log.v(TAG, getMessage(text)); } 17 18 public void a (boolean flag, String text) { 19 if (!flag) { 20 e(text); 21 } 22 } 23 24 public void toast (String text) { 25 Toast.makeText(App.getInstance(), text, Toast.LENGTH_SHORT).show(); 26 e(text); 27 } 28 public void toast (int resId) { 29 toast(App.getInstance().getResources().getText(resId).toString()); 30 } 31 32 private String getMessage (String text) { 33 return className + text; 34 } 35 }
以上是关于Logx.java的主要内容,如果未能解决你的问题,请参考以下文章