OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging | 5 import logging |
6 | 6 |
7 from devil.android import logcat_monitor | 7 from devil.android import logcat_monitor |
8 from devil.utils import reraiser_thread | 8 from devil.utils import reraiser_thread |
9 from pylib.utils import logdog_helper | 9 from pylib.utils import logdog_helper |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 self._StartRecording() | 52 self._StartRecording() |
53 | 53 |
54 def _StartRecording(self): | 54 def _StartRecording(self): |
55 """Starts recording logcat to file. | 55 """Starts recording logcat to file. |
56 | 56 |
57 Write logcat to stream at the same time. | 57 Write logcat to stream at the same time. |
58 """ | 58 """ |
59 def record_to_stream(): | 59 def record_to_stream(): |
60 if self._logdog_stream: | 60 if self._logdog_stream: |
61 for data in self._adb.Logcat(filter_specs=self._filter_specs, | 61 for data in self._adb.Logcat(filter_specs=self._filter_specs, |
62 logcat_format='threadtime'): | 62 logcat_format='threadtime', |
| 63 iter_timeout=0.08): |
63 if self._stop_recording_event.isSet(): | 64 if self._stop_recording_event.isSet(): |
64 return | 65 return |
65 self._logdog_stream.write(data + '\n') | 66 if data: |
| 67 self._logdog_stream.write(data + '\n') |
| 68 if self._stop_recording_event.isSet(): |
| 69 return |
66 | 70 |
67 self._stop_recording_event.clear() | 71 self._stop_recording_event.clear() |
68 if not self._record_thread: | 72 if not self._record_thread: |
69 self._record_thread = reraiser_thread.ReraiserThread(record_to_stream) | 73 self._record_thread = reraiser_thread.ReraiserThread(record_to_stream) |
70 self._record_thread.start() | 74 self._record_thread.start() |
71 | 75 |
72 def Close(self): | 76 def Close(self): |
73 """Override parent's close method.""" | 77 """Override parent's close method.""" |
74 pass | 78 pass |
75 | 79 |
76 def __del__(self): | 80 def __del__(self): |
77 """Override parent's delete method.""" | 81 """Override parent's delete method.""" |
78 pass | 82 pass |
OLD | NEW |