简体   繁体   English

如何解析Chrome Developer Tools中的console.log?

[英]How to parse console.log in Chrome Developer Tools?

Now I am trying to unit test the a simple Phonegap application. 现在我正在尝试对一个简单的Phonegap应用程序进行单元测试。 Especially, I want to test the vibration function in this application. 特别是,我想在这个应用中测试振动功能。 This issue is described here . 此处描述此问题。

In the proposed solution, vibration event is written to the Chrome's log by calling console.log() . 在建议的解决方案中,通过调用console.log()将振动事件写入Chrome的日志。 In order to write unit test, I want to parse Chrome's log after that. 为了编写单元测试,我想在此之后解析Chrome的日志。 Is it possible to do that from JavaScript? 是否可以通过JavaScript实现这一目标?

In this reference question , the content of log is written to disk first. 在此参考问题中 ,日志的内容首先写入磁盘。 I also wonder if it is possible to read the log without saving it to disk. 我也想知道是否可以在不将其保存到磁盘的情况下读取日志。

My answer in the referenced question gave you a way to log to the console, but you could replace that logic in the abstraction with anything you want. 我在引用问题中的答案为您提供了一种登录控制台的方法,但您可以将抽象中的逻辑替换为您想要的任何内容。 You can add the vibration events to a dictionary or an array and then process those values later. 您可以将振动事件添加到字典或数组中,然后再处理这些值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM