ChromeDevTools / awesome-chrome-devtools

Awesome tooling and resources in the Chrome DevTools & DevTools Protocol ecosystem
https://github.com/ChromeDevTools/awesome-chrome-devtools#readme
Creative Commons Zero v1.0 Universal
6.04k stars 349 forks source link

Capture Console? #109

Open johnaweiss opened 4 years ago

johnaweiss commented 4 years ago

Beginner question:

Is it possible to capture all chrome console messages using javascript? This would be a stand-alone chrome browser, not headless. Running inside the same browser-instance-- not a client/remote browser.

What's the simplest, most lightweight solution?

thx!

Garbee commented 4 years ago

I don't believe there is any exposure to intercept those messages. What is your use-case for needing such a feature?

johnaweiss commented 4 years ago

Display them on a front-end IDE, embedded in a webpage, using the local JS engine. 

Garbee commented 4 years ago

IDEs tend to connect using remote debugging which allows API access via the Chrome DevTools Protocol. That way your IDE is the debugger for the app rather than having DevTools open and your IDE. That's how they tend to get access to the logs.

Would using the remote debugging setup not work for some reason?

Yash-Singh1 commented 3 years ago

I had a similar problem. My solution was to edit the console functions: https://github.com/Yash-Singh1/zoom.js/blob/master/test/auto.js#L3

o0101 commented 1 week ago

Hey @johnaweiss and @Yash-Singh1 this will probably be too late for you but for anyone else who wants this in future: you could proxy the debugger front-end. I have created a project that does that, here: devtoolium

You could fork this and implement your own interception