diff options
author | Evan Charlton <evancharlton@gmail.com> | 2013-05-30 19:28:48 -0700 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2013-06-26 15:06:33 -0700 |
commit | 8c5daf39f32ed5ed4e5dc8aa78cbcf5e169c3e4e (patch) | |
tree | 718fa9af94876a2d5ff1d4bfdd6305c04d28b99e /src | |
parent | faedb154756d05748f10c6f2580f349fc7008dc7 (diff) | |
download | volley-8c5daf39f32ed5ed4e5dc8aa78cbcf5e169c3e4e.tar.gz |
Allow per-app VolleyLog tags
To clean up the logs when multiple apps are using Volley, optionally
customize the VolleyLog tag so that the app has its own namespace.
Change-Id: I5b2129ab41bcfb7f309d324f696f905c98833551
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/volley/VolleyLog.java | 18 | ||||
-rw-r--r-- | src/com/android/volley/toolbox/Volley.java | 1 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/com/android/volley/VolleyLog.java b/src/com/android/volley/VolleyLog.java index b1282a1..6684690 100644 --- a/src/com/android/volley/VolleyLog.java +++ b/src/com/android/volley/VolleyLog.java @@ -27,7 +27,23 @@ import java.util.Locale; public class VolleyLog { public static String TAG = "Volley"; - public static final boolean DEBUG = Log.isLoggable(TAG, Log.VERBOSE); + public static boolean DEBUG = Log.isLoggable(TAG, Log.VERBOSE); + + /** + * Customize the log tag for your application, so that other apps + * using Volley don't mix their logs with yours. + * <br /> + * Enable the log property for your tag before starting your app: + * <br /> + * {@code adb shell setprop log.tag.<tag>} + */ + public static void setTag(String tag) { + d("Changing log tag to %s", tag); + TAG = tag; + + // Reinitialize the DEBUG "constant" + DEBUG = Log.isLoggable(TAG, Log.VERBOSE); + } public static void v(String format, Object... args) { if (DEBUG) { diff --git a/src/com/android/volley/toolbox/Volley.java b/src/com/android/volley/toolbox/Volley.java index 1304045..0e04e87 100644 --- a/src/com/android/volley/toolbox/Volley.java +++ b/src/com/android/volley/toolbox/Volley.java @@ -45,7 +45,6 @@ public class Volley { String userAgent = "volley/0"; try { String packageName = context.getPackageName(); - PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0); userAgent = packageName + "/" + info.versionCode; } catch (NameNotFoundException e) { |