如何打印的logcat日志的命令提示符

如何打印的logcat日志的命令提示符

本文介绍了如何打印的logcat日志的命令提示符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行的情况显示在CMD提示。每当有失败我打印的字符串(显示在CMD提示符)。当场景出现故障时,是否可以从打印日志的logcat日志代码段的命令提示符?

I'm running scenarios in UIAutomator.My output is displayed in CMD prompt. Whenever there is a failure i'm printing strings (displayed in Cmd prompt). When the scenarios fails, Is it possible to print the log snippet from logcat logs to cmd prompt?

推荐答案

晚的答案,但迟到总比不到好; - )

Late Answer, but better late than never ;-)

您可以构造一个BufferedReader从logcat的内容是这样的:

You can construct a BufferedReader that reads from logcat like this:

  BufferedReader bufferedReader = new BufferedReader(
                new InputStreamReader(Runtime.getRuntime().exec("logcat -d").getInputStream()));

,然后继续使用的BufferedReader 获取文本内容和往常一样,并打印为例来的命令提示符,你想要的。
不知道这是最好的做法做这种方式,但它的作品。

and then continue using BufferedReader for getting the text content as usual and print for example to Cmd prompt as you wanted.Not sure if that is the best practice doing it this way, but it works.

这篇关于如何打印的logcat日志的命令提示符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 19:44