Java tutorial
//package com.java2s; import android.util.Log; public class Main { public static final String LOGTAG = "LCChatKit"; public static boolean debugEnabled = false; public static void e(String... s) { if (debugEnabled) { Log.e(LOGTAG, getDebugInfo() + getLogInfoByArray(s)); } } private static String getDebugInfo() { Throwable stack = new Throwable().fillInStackTrace(); StackTraceElement[] trace = stack.getStackTrace(); int n = 2; return trace[n].getClassName() + " " + trace[n].getMethodName() + "()" + ":" + trace[n].getLineNumber() + " "; } private static String getLogInfoByArray(String[] infos) { StringBuilder sb = new StringBuilder(); for (String info : infos) { sb.append(info); sb.append(" "); } return sb.toString(); } }