| OLD | NEW |
| 1 # Logging # | 1 # Logging # |
| 2 | 2 |
| 3 [TOC] | 3 [TOC] |
| 4 | 4 |
| 5 | 5 |
| 6 ## Overview | 6 ## Overview |
| 7 | 7 |
| 8 Logging used to be done using Android's [android.util.Log] | 8 Logging used to be done using Android's [android.util.Log] |
| 9 (http://developer.android.com/reference/android/util/Log.html). | 9 (https://developer.android.com/reference/android/util/Log.html). |
| 10 | 10 |
| 11 A wrapper on that is now available: org.chromium.base.Log. It is designed to | 11 A wrapper on that is now available: org.chromium.base.Log. It is designed to |
| 12 write logs as belonging to logical groups going beyond single classes, and to | 12 write logs as belonging to logical groups going beyond single classes, and to |
| 13 make it easy to switch logging on or off for individual groups. | 13 make it easy to switch logging on or off for individual groups. |
| 14 | 14 |
| 15 Usage: | 15 Usage: |
| 16 | 16 |
| 17 ```java | 17 ```java |
| 18 private static final String TAG = "YourModuleTag"; | 18 private static final String TAG = "YourModuleTag"; |
| 19 ... | 19 ... |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 198 |
| 199 ```shell | 199 ```shell |
| 200 export ANDROID_LOG_TAGS="cr_YourModuleTag:D *:S" | 200 export ANDROID_LOG_TAGS="cr_YourModuleTag:D *:S" |
| 201 ``` | 201 ``` |
| 202 | 202 |
| 203 The syntax does not support tag expansion or regular expressions other than `*` | 203 The syntax does not support tag expansion or regular expressions other than `*` |
| 204 for all tags. Please use `grep` or a similar tool to refine your filters | 204 for all tags. Please use `grep` or a similar tool to refine your filters |
| 205 further. | 205 further. |
| 206 | 206 |
| 207 For more, see the [related page on developer.android.com] | 207 For more, see the [related page on developer.android.com] |
| 208 (http://developer.android.com/tools/debugging/debugging-log.html#filteringOutput
) | 208 (https://developer.android.com/tools/debugging/debugging-log.html#filteringOutpu
t) |
| 209 | 209 |
| 210 ## Logs in JUnit tests | 210 ## Logs in JUnit tests |
| 211 | 211 |
| 212 We use [robolectric](http://robolectric.org/) to run our JUnit tests. It | 212 We use [robolectric](http://robolectric.org/) to run our JUnit tests. It |
| 213 replaces some of the Android framework classes with "Shadow" classes | 213 replaces some of the Android framework classes with "Shadow" classes |
| 214 to ensure that we can run our code in a regular JVM. `android.util.Log` is one | 214 to ensure that we can run our code in a regular JVM. `android.util.Log` is one |
| 215 of those replaced classes, and by default calling `Log` methods doesn't print | 215 of those replaced classes, and by default calling `Log` methods doesn't print |
| 216 anything. | 216 anything. |
| 217 | 217 |
| 218 That default is not changed in the normal configuration, but if you need to | 218 That default is not changed in the normal configuration, but if you need to |
| 219 enable logging locally or for a specific test, just add those few lines to your | 219 enable logging locally or for a specific test, just add those few lines to your |
| 220 test: | 220 test: |
| 221 | 221 |
| 222 ```java | 222 ```java |
| 223 @Before | 223 @Before |
| 224 public void setUp() { | 224 public void setUp() { |
| 225 ShadowLog.stream = System.out; | 225 ShadowLog.stream = System.out; |
| 226 //you other setup here | 226 //you other setup here |
| 227 } | 227 } |
| 228 ``` | 228 ``` |
| OLD | NEW |