Skip to content

Instantly share code, notes, and snippets.

@mochico
Created March 4, 2014 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mochico/9345769 to your computer and use it in GitHub Desktop.
Save mochico/9345769 to your computer and use it in GitHub Desktop.
debug log for android
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