def once(self):
# check if there is a request to get and clear accumulated logs
msg = self._recv(timeout=0)
if msg == 'get':
self._send(self.log_buf.getvalue())
self.log_buf = StringIO()
# is there new logcat output to read?
if not self.poller.poll(500): # millisecond timeout
return
# read logcat output and store it in a buffer, optionally to file too
log = os.read(self.cmd_fd, 1000)
if self.log_file:
self.log_file.write(log)
self.log_file.flush()
if self.log_buf.tell() > LOGBUF_MAXSIZE:
self.log_buf = StringIO() # start over to avoid OOM
self.log_buf.write(log)
评论列表
文章目录