summaryrefslogtreecommitdiffstats
path: root/docs/android_logging.md
diff options
context:
space:
mode:
authordgn <dgn@chromium.org>2015-09-18 12:20:51 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-18 19:21:52 +0000
commit38736db9311bb4b03e6f555d71dc98b7fd341d37 (patch)
tree600dd3a17bf9af9dcf44c0aad546161578ef8970 /docs/android_logging.md
parent252494591ae4a05cea3bab34345659f59ff7740d (diff)
downloadchromium_src-38736db9311bb4b03e6f555d71dc98b7fd341d37.zip
chromium_src-38736db9311bb4b03e6f555d71dc98b7fd341d37.tar.gz
chromium_src-38736db9311bb4b03e6f555d71dc98b7fd341d37.tar.bz2
[android] Change the recommended log tag format to "cr_foo"
This is to ensure that log tags are not elided when retrieving logcat output from crash reports. The log function has been modified to make the transition easier and avoid specifying the prefix everywhere. This patch also moves some eliding testing from instrumentation tests to junit tests, and adds a test to ensure that the new tag format is not elided. BUG=533072 Review URL: https://codereview.chromium.org/1354723004 Cr-Commit-Position: refs/heads/master@{#349733}
Diffstat (limited to 'docs/android_logging.md')
-rw-r--r--docs/android_logging.md23
1 files changed, 12 insertions, 11 deletions
diff --git a/docs/android_logging.md b/docs/android_logging.md
index 3068dc5..d7d248f 100644
--- a/docs/android_logging.md
+++ b/docs/android_logging.md
@@ -15,7 +15,7 @@ make it easy to switch logging on or off for individual groups.
Usage:
```java
-private static final String TAG = "cr.YourModuleTag";
+private static final String TAG = "YourModuleTag";
...
Log.i(TAG, "Logged INFO message.");
Log.d(TAG, "Some DEBUG info: %s", data);
@@ -24,12 +24,13 @@ Log.d(TAG, "Some DEBUG info: %s", data);
Output:
```
-I/cr.YourModuleTag: ( 999): Logged INFO message
-D/cr.YourModuleTag: ( 999): [MyClass.java:42] Some DEBUG info: data.toString
+I/cr_YourModuleTag: ( 999): Logged INFO message
+D/cr_YourModuleTag: ( 999): [MyClass.java:42] Some DEBUG info: data.toString
```
Here, **TAG** will be a feature or package name, "MediaRemote" or "NFC" for
-example. In most cases, the class name is not needed.
+example. In most cases, the class name is not needed. It will be prepended by
+the "cr_" prefix to make obvious which logs are coming from Chrome.
### Verbose and Debug logs have special handling ###
@@ -50,10 +51,10 @@ Log.i(TAG, "An error happened: %s", e)
```
```
-I/cr.YourModuleTag: ( 999): An error happened: This is the exception's message
-I/cr.YourModuleTag: ( 999): java.lang.Exception: This is the exception's message
-I/cr.YourModuleTag: ( 999): at foo.bar.MyClass.test(MyClass.java:42)
-I/cr.YourModuleTag: ( 999): ...
+I/cr_YourModuleTag: ( 999): An error happened: This is the exception's message
+I/cr_YourModuleTag: ( 999): java.lang.Exception: This is the exception's message
+I/cr_YourModuleTag: ( 999): at foo.bar.MyClass.test(MyClass.java:42)
+I/cr_YourModuleTag: ( 999): ...
```
Having the exception as last parameter doesn't prevent it from being used for
@@ -187,16 +188,16 @@ Logcat allows filtering by specifying tags and the associated level:
```shell
adb logcat [TAG_EXPR:LEVEL]...
-adb logcat cr.YourModuleTag:D *:S
+adb logcat cr_YourModuleTag:D *:S
```
This shows only logs having a level higher or equal to DEBUG for
-`cr.YourModuleTag`, and SILENT (nothing is logged at this level or higher, so it
+`cr_YourModuleTag`, and SILENT (nothing is logged at this level or higher, so it
silences the tags) for everything else. You can persist a filter by setting an
environment variable:
```shell
-export ANDROID_LOG_TAGS="cr.YourModuleTag:D *:S"
+export ANDROID_LOG_TAGS="cr_YourModuleTag:D *:S"
```
For more, see the [related page on developer.android.com]