可以在adb logcat中清除指定的消息或行,而不是全部清除吗? [英] Can a specified message or row be cleared in the adb logcat instead of clearing all?

查看:634
本文介绍了可以在adb logcat中清除指定的消息或行,而不是全部清除吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Monkeyrunner(自动化)在Android设备(三星S2)上测试应用程序,并且由于它不允许我在屏幕上看到图像模式,因此我不得不依靠adb logcat(使用Windows)查找特定消息,以便知道何时为我的自动化脚本加载了下一页.

I am using Monkeyrunner (automation) to test an app on an Android device (Samsung S2), and since it does not allow me to see image patterns on the screen, I have to rely on the adb logcat (using Windows) to look for specific messages in order to know when the next page has loaded for my automation script.

并且为了在logcat中查找特定的(唯一的)消息,对于我的Monkeyrunner脚本,我必须清除所有的adb日志,然后执行搜索.

And in order to look for specific (unique) messages in the logcat, for my monkeyrunner script, I have to CLEAR out ALL the adb logs, then perform the search.

是否有办法只清除logcat日志中与特定标签,消息,文本或任何其他内容(!)相匹配的行?而不是清除所有内容?

Is there a way to clear out only the line(s) that match a specific tag, message, text, or whatever(!), within the logcat log? Instead of clearing out everything?

命令行adb功能是否允许您清除特定的行,或者是全有还是全无?

Does the command line adb functionality allow you to clear specific lines, or is it an all or nothing kinda thing?

清除所有logcat long都可以,但是最好清除某些消息,以便在/当应用崩溃或某些需要详细信息进行故障排除的事件时,可以看到所有日志直到崩溃(或重大事件).因为如果一切都清除了,我将无法查看logcat日志来解决任何问题.

Clearing out all the logcat longs works, but it would be nice to ONLY clear out certain messages so that if/when there is an app crash, or some event where I need details for troubleshooting, I can see all the logs leading up to the crash (or significant event). Because if everything is cleared out, there is no way for me to see the logcat logs to troubleshoot whatever.

:::更多信息:::

::: MORE INFORMATION :::

这是我当前用来清除所有日志的功能.

Here is the function I currently use to clear out all the logs.

def clearAdb():
    p = subprocess.Popen("adb logcat -v time", shell=True, cwd="C:\Users\<USERNAME>AppData\Local\Android\sdk\platform-tools", stdout=subprocess.PIPE)
    subprocess.Popen("adb logcat -c", shell=True, cwd="C:\Users\<USERNAME>AppData\Local\Android\sdk\platform-tools", stdout=subprocess.PIPE)
    print("::: ADB cleared :::")

..这是我如何查找logcat日志的示例.这个adb函数无限期地等待特定的adb消息,并在看到时进行处理.

..and here's an example of how I am looking for the logcat log. This adb function waits indefinitely for a specific adb message, and process when seen.

def adb(message):
    p = subprocess.Popen("adb logcat -v time", shell=True, cwd="C:\Users\<USERNAME>\AppData\Local\Android\sdk\platform-tools", stdout=subprocess.PIPE)
    for line in p.stdout:
        if message in line:
            print("Got 'em")
            break
        else:
            continue

...这就是我目前一起使用这些功能的方式...

...and this is how I currently use the functions together...

clearAdb()
adb("identifyGamePackage. com.tfg.nameofapplication")

推荐答案

要将logcat输出限制为某些时刻之后发生的消息,您不必清除日志.而是使用logcat -T <timestamp>过滤器.支持的时间戳格式取决于Android版本-请参见logcat -h输出中的-T段落.

To limit logcat output to messages which happened after certain moment you do not have to clear the log. Instead use logcat -T <timestamp> filter. Supported timestamp formats depend on the Android version - see -T paragraph in logcat -h output.

这篇关于可以在adb logcat中清除指定的消息或行,而不是全部清除吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆