Chrome: redirect console.log to stdout
Asked Answered
L

0

6

I am investigating easy ways to reuse tests that output the TAP format.

I want to be able to start Chrome from the command line and capture console.log output

If I have the following file called index.html

<script>
  console.log('beep boop!')
</script>

...can I then capture from the command line by doing something like this:

# start-crome --flag > out.txt

...and have out.txt contain "beep boop!"?

EDIT: Yes there are other questions that cover saving console.log to file manually. I want to pipe console log to stdout, so that debug information can be analysed in an automated unix setting

Leland answered 9/3, 2016 at 11:11 Comment(9)
You can make non windows Chrome write to stderr with --enable-logging=stderr although you will get a lot of other messages as wellMv
Yes- but you really get A LOT of random log output, that is impossible to parse. Plus its "incorrect" that normal log info should be directed to stderr instead of stdoutLeland
Possible duplicate of Save the console.log in Chrome to a fileStuyvesant
@Stuyvesant that is a question about saving console.log (something which is now fairly trivial to do manually). I want to pipe console log to stdout, so that debug information can be analysed in an automated unix settingLeland
@fergie a solution to this problem could be to save console.log and pipe the information from this file with the command tail -f chrome_debug.log | AnalyzerStuyvesant
@Stuyvesant if there is a way to save the console.log to file programatically, then yes, that would work. "Save the console.log to file programatically" is the crux of the question.Leland
@Leland seems that lib debugout do what you want, Can you add libraries?Stuyvesant
@Stuyvesant no- debugout does not redirect console.log to stdoutLeland
You would get lots of random output, but you could add a special tag to your output and then grep for it.Ancient

© 2022 - 2024 — McMap. All rights reserved.