user1450553
user1450553

Reputation: 91

Console log for Chrome DevTools API

I am extending Google Chrome with the "chrome.devtools.panels.create" API, it means that I have now some logic in my browser by which I need to debug.

Is there anyway to see the Console log / Debug my DevTools additions?

Upvotes: 6

Views: 1910

Answers (2)

jdprc06
jdprc06

Reputation: 360

You need to eval a script in the inspectedWindow:

chrome.devtools.inspectedWindow.eval('console.log("test")')

Upvotes: 2

Silviu-Marian
Silviu-Marian

Reputation: 10927

If all you need is console.log you can wrap it up. Actually it works for any other function, not just console.log but here's example for wrapping console.log:

console._log = console.log;
console.log = function(){ 
    // you can do whatever you want with arguments, output to div, alert / etc.
    return console._log.apply(console,arguments); 
};

Upvotes: 2

Related Questions