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 }