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 (http://developer.android.com/reference/android/util/Log.html). |
10 | 10 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 (http://developer.android.com/tools/debugging/debugging-log.html#filteringOutput
) |
| 209 |
| 210 ## Logs in JUnit tests |
| 211 |
| 212 We use [robolectric](http://robolectric.org/) to run our JUnit tests. It |
| 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 |
| 215 of those replaced classes, and by default calling `Log` methods doesn't print |
| 216 anything. |
| 217 |
| 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 |
| 220 test: |
| 221 |
| 222 ```java |
| 223 @Before |
| 224 public void setUp() { |
| 225 ShadowLog.stream = System.out; |
| 226 //you other setup here |
| 227 } |
| 228 ``` |
OLD | NEW |