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

Fergie
  • 5,933
  • 7
  • 38
  • 42
  • 1
    You can make non windows Chrome write to stderr with --enable-logging=stderr although you will get a lot of other messages as well – Alex K. Mar 09 '16 at 11:21
  • 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 stdout – Fergie Mar 09 '16 at 11:37
  • Possible duplicate of [Save the console.log in Chrome to a file](http://stackoverflow.com/questions/7627113/save-the-console-log-in-chrome-to-a-file) – dloeda Mar 09 '16 at 15:34
  • @dloeda 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 setting – Fergie Mar 10 '16 at 10:54
  • @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 | Analyzer` – dloeda Mar 10 '16 at 11:01
  • @dloeda 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. – Fergie Mar 10 '16 at 11:22
  • @Fergie seems that lib [debugout](https://github.com/inorganik/debugout.js) do what you want, Can you add libraries? – dloeda Mar 10 '16 at 15:39
  • @dloeda no- debugout does not redirect console.log to stdout – Fergie Mar 28 '16 at 13:08
  • You would get lots of random output, but you could add a special tag to your output and then grep for it. – Robert Moore Jul 08 '17 at 19:50

0 Answers0