|
25 | 25 |
|
26 | 26 | namespace dart {
|
27 | 27 |
|
| 28 | +DEFINE_FLAG(bool, |
| 29 | + android_log_to_stderr, |
| 30 | + false, |
| 31 | + "Send Dart VM logs to stdout and stderr instead of the Android " |
| 32 | + "system logs."); |
| 33 | + |
28 | 34 | // Android CodeObservers.
|
29 | 35 |
|
30 | 36 | #ifndef PRODUCT
|
@@ -255,8 +261,12 @@ DART_NOINLINE uintptr_t OS::GetProgramCounter() {
|
255 | 261 | void OS::Print(const char* format, ...) {
|
256 | 262 | va_list args;
|
257 | 263 | va_start(args, format);
|
258 |
| - // Forward to the Android log for remote access. |
259 |
| - __android_log_vprint(ANDROID_LOG_INFO, "DartVM", format, args); |
| 264 | + if (FLAG_android_log_to_stderr) { |
| 265 | + vfprintf(stderr, format, args); |
| 266 | + } else { |
| 267 | + // Forward to the Android log for remote access. |
| 268 | + __android_log_vprint(ANDROID_LOG_INFO, "DartVM", format, args); |
| 269 | + } |
260 | 270 | va_end(args);
|
261 | 271 | }
|
262 | 272 |
|
@@ -332,8 +342,12 @@ void OS::RegisterCodeObservers() {
|
332 | 342 | void OS::PrintErr(const char* format, ...) {
|
333 | 343 | va_list args;
|
334 | 344 | va_start(args, format);
|
335 |
| - // Forward to the Android log for remote access. |
336 |
| - __android_log_vprint(ANDROID_LOG_ERROR, "DartVM", format, args); |
| 345 | + if (FLAG_android_log_to_stderr) { |
| 346 | + vfprintf(stderr, format, args); |
| 347 | + } else { |
| 348 | + // Forward to the Android log for remote access. |
| 349 | + __android_log_vprint(ANDROID_LOG_ERROR, "DartVM", format, args); |
| 350 | + } |
337 | 351 | va_end(args);
|
338 | 352 | }
|
339 | 353 |
|
|
0 commit comments