Created
April 21, 2012 15:23
-
-
Save gin0606/2437713 to your computer and use it in GitHub Desktop.
debug = trueでデバッグモード。Log.dとかいちいちif文で出したり出さなかったり、debug用のコードの切り替えめんどかったので書いた。Logクラスのメソッドまるっとアレしてるだけ。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gin.no.utils; | |
import android.util.Log; | |
public class DebugLog { | |
private static boolean debug = false; | |
public static int d(String tag, String msg) { | |
return debug ? Log.d(tag, msg) : -1; | |
} | |
public static int d(String tag, String msg, Throwable tr) { | |
return debug ? Log.d(tag, msg, tr) : -1; | |
} | |
public static int e(String tag, String msg) { | |
return debug ? Log.e(tag, msg) : -1; | |
} | |
public static int e(String tag, String msg, Throwable tr) { | |
return debug ? Log.e(tag, msg, tr) : -1; | |
} | |
public static String getStackTraceString(Throwable tr) { | |
return debug ? Log.getStackTraceString(tr) : null; | |
} | |
public static int i(String tag, String msg) { | |
return debug ? Log.i(tag, msg) : -1; | |
} | |
public static int i(String tag, String msg, Throwable tr) { | |
return debug ? Log.i(tag, msg, tr) : -1; | |
} | |
public static boolean isLoggable(String tag, int level) { | |
return Log.isLoggable(tag, level); | |
} | |
public static int println(int priority, String tag, String msg) { | |
return debug ? Log.println(priority, tag, msg) : -1; | |
} | |
public static int v(String tag, String msg) { | |
return debug ? Log.v(tag, msg) : -1; | |
} | |
public static int v(String tag, String msg, Throwable tr) { | |
return debug ? Log.v(tag, msg, tr) : -1; | |
} | |
public static int w(String tag, Throwable tr) { | |
return debug ? Log.w(tag, tr) : -1; | |
} | |
public static int w(String tag, String msg, Throwable tr) { | |
return debug ? Log.w(tag, msg, tr) : -1; | |
} | |
public static int w(String tag, String msg) { | |
return debug ? Log.w(tag, msg) : -1; | |
} | |
public static int wtf(String tag, Throwable tr) { | |
return debug ? Log.wtf(tag, tr) : -1; | |
} | |
public static int wtf(String tag, String msg) { | |
return debug ? Log.wtf(tag, msg) : -1; | |
} | |
public static int wtf(String tag, String msg, Throwable tr) { | |
return debug ? Log.wtf(tag, msg, tr) : -1; | |
} | |
public static boolean isDebugMode() { | |
return debug; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment