123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- package epson.print.Util;
- import android.util.Log;
- import epson.print.CommonDefine;
- public final class EPLog {
- public static final String TAG = "Epson App";
- private static boolean isDebug = false;
- public static final void heap(String str) {
- }
- private static String null2str(String str) {
- return str == null ? "(null)" : str;
- }
- private EPLog() {
- }
- public static void setDebuggable(boolean z) {
- if (z) {
- isDebug = true;
- } else {
- isDebug = false;
- }
- }
- public static void v() {
- if (isDebug) {
- Log.v("Epson App", getMetaInfo());
- }
- }
- public static void v(String str) {
- if (isDebug) {
- Log.v("Epson App", getMetaInfo() + null2str(str));
- }
- }
- public static void v(String str, String str2) {
- if (isDebug) {
- Log.v(str, getMetaInfo() + null2str(str2));
- }
- }
- public static void d() {
- if (isDebug) {
- Log.d("Epson App", getMetaInfo());
- }
- }
- public static void d(String str) {
- if (isDebug) {
- Log.d("Epson App", getMetaInfo() + null2str(str));
- }
- }
- public static void d(String str, String str2) {
- if (isDebug) {
- Log.d(str, getMetaInfo() + null2str(str2));
- }
- }
- public static void i() {
- if (isDebug) {
- Log.i("Epson App", getMetaInfo());
- }
- }
- public static void i(String str) {
- if (isDebug) {
- Log.i("Epson App", getMetaInfo() + null2str(str));
- }
- }
- public static void i(String str, String str2) {
- if (isDebug) {
- Log.i(str, getMetaInfo() + null2str(str2));
- }
- }
- public static void w(String str) {
- if (isDebug) {
- Log.w("Epson App", getMetaInfo() + null2str(str));
- }
- }
- public static void w(String str, String str2) {
- if (isDebug) {
- Log.w(str, getMetaInfo() + null2str(str2));
- }
- }
- public static void w(String str, Throwable th) {
- if (isDebug) {
- Log.w("Epson App", getMetaInfo() + null2str(str), th);
- printThrowable(th);
- if (th.getCause() != null) {
- printThrowable(th.getCause());
- }
- }
- }
- public static void w(String str, String str2, Throwable th) {
- if (isDebug) {
- Log.w(str, getMetaInfo() + null2str(str2), th);
- printThrowable(str, th);
- if (th.getCause() != null) {
- printThrowable(th.getCause());
- }
- }
- }
- public static void e(String str) {
- if (isDebug) {
- Log.e("Epson App", getMetaInfo() + null2str(str));
- }
- }
- public static void e(String str, String str2) {
- if (isDebug) {
- Log.e(str, getMetaInfo() + null2str(str2));
- }
- }
- public static void e(String str, Throwable th) {
- if (isDebug) {
- Log.e("Epson App", getMetaInfo() + null2str(str), th);
- printThrowable(th);
- if (th.getCause() != null) {
- printThrowable(th.getCause());
- }
- }
- }
- public static void e(String str, String str2, Throwable th) {
- if (isDebug) {
- Log.e(str, getMetaInfo() + null2str(str2), th);
- printThrowable(str, th);
- if (th.getCause() != null) {
- printThrowable(th.getCause());
- }
- }
- }
- public static void e(Throwable th) {
- if (isDebug) {
- printThrowable(th);
- if (th.getCause() != null) {
- printThrowable(th.getCause());
- }
- }
- }
- private static void printThrowable(Throwable th) {
- Log.e("Epson App", th.getClass().getName() + ": " + th.getMessage());
- for (StackTraceElement stackTraceElement : th.getStackTrace()) {
- Log.e("Epson App", " at " + getMetaInfo(stackTraceElement));
- }
- }
- private static void printThrowable(String str, Throwable th) {
- Log.e(str, th.getClass().getName() + ": " + th.getMessage());
- for (StackTraceElement stackTraceElement : th.getStackTrace()) {
- Log.e("Epson App", " at " + getMetaInfo(stackTraceElement));
- }
- }
- private static String getMetaInfo() {
- return getMetaInfo(Thread.currentThread().getStackTrace()[4]);
- }
- public static String getMetaInfo(StackTraceElement stackTraceElement) {
- StringBuffer stringBuffer = new StringBuffer();
- String className = stackTraceElement.getClassName();
- String substring = className.substring(className.lastIndexOf(CommonDefine.DOT) + 1);
- String methodName = stackTraceElement.getMethodName();
- int lineNumber = stackTraceElement.getLineNumber();
- stringBuffer.append("[");
- stringBuffer.append(substring);
- stringBuffer.append("#");
- stringBuffer.append(methodName);
- stringBuffer.append(":");
- stringBuffer.append(lineNumber);
- stringBuffer.append("]");
- return new String(stringBuffer);
- }
- public static final void heap() {
- heap("Epson App");
- }
- }
|