Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6629)

Unified Diff: base/android/java/src/org/chromium/base/Log.java

Issue 1131903007: [Android log] Promote using hardcoded string tags (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add length check and test, remove java tag check Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/android/java/src/org/chromium/base/Log.java
diff --git a/base/android/java/src/org/chromium/base/Log.java b/base/android/java/src/org/chromium/base/Log.java
index 4c79a4d507f3f5c255c5df224a12ea0282f0a992..c6cc3503827ccc62c8be3ba6e479b650e847f971 100644
--- a/base/android/java/src/org/chromium/base/Log.java
+++ b/base/android/java/src/org/chromium/base/Log.java
@@ -29,7 +29,7 @@
*
* Usage:
* <pre>
- * private static final String TAG = Log.makeTag("Group");
+ * private static final String TAG = "cr.Group";
*
* private void myMethod(String awesome) {
* Log.i(TAG, "My %s message.", awesome);
@@ -45,12 +45,10 @@
*
* Set the log level for a given group:
* <pre>
- * $ adb shell setprop log.tag.chromium.Group VERBOSE
+ * $ adb shell setprop log.tag.cr.Group VERBOSE
* </pre>
*/
public class Log {
- private static final String BASE_TAG = "cr";
-
/** Convenience property, same as {@link android.util.Log#ASSERT}. */
public static final int ASSERT = android.util.Log.ASSERT;
@@ -98,10 +96,12 @@ private static String formatLogWithStack(String messageTemplate, Object... param
*
* @see android.util.Log#isLoggable(String, int)
* @throws IllegalArgumentException if the tag is too long.
+ * @deprecated Directly use a string (e.g. "cr.Tag") in your class. See http://crbug.com/485772
*/
+ @Deprecated
public static String makeTag(String groupTag) {
- if (TextUtils.isEmpty(groupTag)) return BASE_TAG;
- String tag = BASE_TAG + "." + groupTag;
+ if (TextUtils.isEmpty(groupTag)) return "cr";
+ String tag = "cr." + groupTag;
if (tag.length() > 23) {
throw new IllegalArgumentException(
"The full tag (" + tag + ") is longer than 23 characters.");
@@ -121,9 +121,7 @@ public static boolean isLoggable(String tag, int level) {
* than 7 parameters, consider building your log message using a function annotated with
* {@link NoSideEffects}.
*
- * @param tag Used to identify the source of a log message. Should be created using
- * {@link #makeTag(String)}.
- *
+ * @param tag Used to identify the source of a log message.
* @param messageTemplate The message you would like logged. It is to be specified as a format
* string.
* @param args Arguments referenced by the format specifiers in the format string. If the last
@@ -193,9 +191,7 @@ public static void v(String tag, String messageTemplate, Object arg1, Object arg
* than 7 parameters, consider building your log message using a function annotated with
* {@link NoSideEffects}.
*
- * @param tag Used to identify the source of a log message. Should be created using
- * {@link #makeTag(String)}.
- *
+ * @param tag Used to identify the source of a log message.
* @param messageTemplate The message you would like logged. It is to be specified as a format
* string.
* @param args Arguments referenced by the format specifiers in the format string. If the last
@@ -259,8 +255,7 @@ public static void d(String tag, String messageTemplate, Object arg1, Object arg
/**
* Sends an {@link android.util.Log#INFO} log message.
*
- * @param tag Used to identify the source of a log message. Should be created using
- * {@link #makeTag(String)}.
+ * @param tag Used to identify the source of a log message.
* @param messageTemplate The message you would like logged. It is to be specified as a format
* string.
* @param args Arguments referenced by the format specifiers in the format string. If the last
@@ -281,8 +276,7 @@ public static void i(String tag, String messageTemplate, Object... args) {
/**
* Sends a {@link android.util.Log#WARN} log message.
*
- * @param tag Used to identify the source of a log message. Should be created using
- * {@link #makeTag(String)}.
+ * @param tag Used to identify the source of a log message.
* @param messageTemplate The message you would like logged. It is to be specified as a format
* string.
* @param args Arguments referenced by the format specifiers in the format string. If the last
@@ -303,8 +297,7 @@ public static void w(String tag, String messageTemplate, Object... args) {
/**
* Sends an {@link android.util.Log#ERROR} log message.
*
- * @param tag Used to identify the source of a log message. Should be created using
- * {@link #makeTag(String)}.
+ * @param tag Used to identify the source of a log message.
* @param messageTemplate The message you would like logged. It is to be specified as a format
* string.
* @param args Arguments referenced by the format specifiers in the format string. If the last
@@ -329,8 +322,7 @@ public static void e(String tag, String messageTemplate, Object... args) {
*
* @see android.util.Log#wtf(String, String, Throwable)
*
- * @param tag Used to identify the source of a log message. Should be created using
- * {@link #makeTag(String)}.
+ * @param tag Used to identify the source of a log message.
* @param messageTemplate The message you would like logged. It is to be specified as a format
* string.
* @param args Arguments referenced by the format specifiers in the format string. If the last

Powered by Google App Engine
This is Rietveld 408576698