VolleyLogpublic class VolleyLog extends Object
Fields Summary |
---|
public static String | TAG | public static boolean | DEBUG |
Methods Summary |
---|
private static java.lang.String | buildMessage(java.lang.String format, java.lang.Object args)Formats the caller's provided message and prepends useful info like
calling thread ID and method name.
String msg = (args == null) ? format : String.format(Locale.US, format, args);
StackTraceElement[] trace = new Throwable().fillInStackTrace().getStackTrace();
String caller = "<unknown>";
// Walk up the stack looking for the first caller outside of VolleyLog.
// It will be at least two frames up, so start there.
for (int i = 2; i < trace.length; i++) {
Class<?> clazz = trace[i].getClass();
if (!clazz.equals(VolleyLog.class)) {
String callingClass = trace[i].getClassName();
callingClass = callingClass.substring(callingClass.lastIndexOf('.") + 1);
callingClass = callingClass.substring(callingClass.lastIndexOf('$") + 1);
caller = callingClass + "." + trace[i].getMethodName();
break;
}
}
return String.format(Locale.US, "[%d] %s: %s",
Thread.currentThread().getId(), caller, msg);
| public static void | d(java.lang.String format, java.lang.Object args)
Log.d(TAG, buildMessage(format, args));
| public static void | e(java.lang.String format, java.lang.Object args)
Log.e(TAG, buildMessage(format, args));
| public static void | e(java.lang.Throwable tr, java.lang.String format, java.lang.Object args)
Log.e(TAG, buildMessage(format, args), tr);
| public static void | setTag(java.lang.String tag)Customize the log tag for your application, so that other apps
using Volley don't mix their logs with yours.
Enable the log property for your tag before starting your app:
{@code adb shell setprop log.tag.<tag>}
d("Changing log tag to %s", tag);
TAG = tag;
// Reinitialize the DEBUG "constant"
DEBUG = Log.isLoggable(TAG, Log.VERBOSE);
| public static void | v(java.lang.String format, java.lang.Object args)
if (DEBUG) {
Log.v(TAG, buildMessage(format, args));
}
| public static void | wtf(java.lang.String format, java.lang.Object args)
Log.wtf(TAG, buildMessage(format, args));
| public static void | wtf(java.lang.Throwable tr, java.lang.String format, java.lang.Object args)
Log.wtf(TAG, buildMessage(format, args), tr);
|
|