Closed abeelan closed 1 year ago
这样用也可以 d.shell("logcat --clear")
d.shell("logcat --clear")
stream = d.shell("logcat", stream=True)
with stream:
f = stream.conn.makefile()
for _ in range(100): # read 100 lines
line = f.readline()
print("Logcat:", line.rstrip())
f.close()
这个方法如何实现一直循环读取 logcat 日志呢
@abeelan 你这个循环不结束不就可以了
现在logcat多了一个新的方法了
Logcat
# filter logcat to file
logcat = d.logcat("logcat.txt", clear=True, re_filter=".*FA.*") # clear default False
# do something else
logcat.stop(timeout=3) # tell thread to stop write, wait for 3s, if not stopped, raise TimeoutError
logcat.stop_nowait() # tell thread to stop write and close file
棒!
使用 adbutils 过程中,要使用
adb logcat -c
这样的命令,所以找到了adb_output()
这个函数,但是发现他的传参是通过 args 接收的,调用:adb_output("logcat", "-c")
,这样感觉比较麻烦呀;直接实现成类似
shell()
的调用方式:adb_output("logcat -c")
会更方便一些,请教下。