在Chrome中,如何将JavaScript控制台输出获取到stdout/stderr

编程入门 行业动态 更新时间:2024-10-15 06:19:34
本文介绍了在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

本文发布于:2023-06-11 14:51:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/637053.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控制台   如何将   Chrome   JavaScript   stderr

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!