dodov
dodov

Reputation: 5854

How to log to DevTools console from a devtools page?

I have a devtools.html file that has a script.js which contains:

console.log('started...')

In manifest.json, I have:

"devtools_page": "devtools.html"

However, when I run my extension and open a DevTools window, I don't see the log. If I throw an error in script.js, I can see that the error occurred in the chrome://extensions page, so I know that this script is loaded. However, that log doesn't appear anywhere. Aren't a devtools page's logs supposed to appear in the DevTools window?

Upvotes: 2

Views: 1435

Answers (1)

woxxom
woxxom

Reputation: 73816

View console.log() messages

  • Undock devtools into a separate window (in devtools toolbar, the three-dot menu)
  • Focus devtools window
  • Press CtrlShifti or CmdShifti to open devtools-on-devtools where you'll see the output

Output in the web page console using chrome.devtools.inspectedWindow.eval:

const foo = {bar: 123};
chrome.devtools.inspectedWindow.eval(`console.log(${JSON.stringify(foo)})`);

Upvotes: 5

Related Questions