在Chrome中,如何将JavaScript控制台输出获取到stdout/stderr [英] In Chrome, how can I get the javascript console output to stdout/stderr

查看:119
本文介绍了在Chrome中,如何将JavaScript控制台输出获取到stdout/stderr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Google Chrome浏览器,并且有一个页面可以将一些信息打印到Javascript控制台-我想将此内容通过管道传递给脚本.

I'm using Google Chrome, and have a page that prints some information to the Javascript console - I want to pipe this to a script.

我已经找到了如何在OS X上显示Chrome的标准输出的方法-通过在终端上运行以下命令(需要新的用户配置文件来确保该命令产生一个新的应用程序,否则我们将打开现有的应用程序并没有输出).

I've found how to display Chrome's stdout on OS X - by running the command below from a Terminal (a new user profile is needed to make sure the command spawns a new application, otherwise we'll open the existing one and get no output).

但是,我要打印到Terminal的只是内部Chrome信息.

However, all I'm getting printed to Terminal is internal Chrome information.

是否可以将所有JS控制台输出打印到stdout/stderr,以便将以下命令的输出通过管道传递到我的脚本?

Is there a way to get all JS console output to be printed to stdout/stderr so that I can pipe the output of the below command to my script?

TIA!

/Applications/Google \ Chrome.app/Contents/MacOS/Google \ Chrome --user-data-dir = temp-dir

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir=temp-dir

推荐答案

  • 从命令行使用以下标志启用记录:

    --enable-logging --v=1

    这会记录Chrome内部所做的所有事情,但同时也会记录所有console.log()消息.日志文件名为 chrome_debug.log ,位于 User Data Directory .

    This logs everything Chrome does internally, but it also logs all the console.log() messages as well. The log file is called chrome_debug.log and is located in the User Data Directory.

    这篇关于在Chrome中,如何将JavaScript控制台输出获取到stdout/stderr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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