Created
March 4, 2014 12:40
-
-
Save mochico/9345769 to your computer and use it in GitHub Desktop.
debug log for android
This file contains 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
import android.util.Log; | |
public class Utils { | |
/** デバッグログ切替 */ | |
public static final boolean isLogging = true; | |
/** | |
* Logメソッドを切り換えられるdebugLog | |
* @param logVal | |
* @param tag | |
* @param message | |
*/ | |
public static void logOut(int logVal, String tag, String message) { | |
if (isLogging) { | |
switch (logVal) { | |
case Log.VERBOSE: | |
Log.v(tag, message); | |
break; | |
case Log.DEBUG: | |
Log.d(tag, message); | |
break; | |
case Log.INFO: | |
Log.i(tag, message); | |
break; | |
case Log.WARN: | |
Log.w(tag, message); | |
break; | |
default: | |
break; | |
} | |
} | |
} | |
/** | |
* タグ指定可能なdebugLog | |
* @param tag | |
* @param message | |
*/ | |
public static void debugLog(String tag, String message) { | |
logOut(Log.DEBUG, tag, message); | |
} | |
/** | |
* オブジェクト名を自動的にTAGにセットするdebugLog | |
* @param object | |
* @param message | |
*/ | |
public static void debugLog(Object object, String message) { | |
debugLog(object.getClass().getSimpleName(), message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment