Adding console entries with server response headers

695 views
Skip to first unread message

Craig Francis

unread,
Jan 19, 2013, 8:46:40 AM1/19/13
to google-chrome-...@googlegroups.com
Looking at projects such as Rails Panel, ChromePHP, PHP-Console, and FirePHP:


They all seem to use headers in the HTTP response to add items to the developer tools console (or equivalent).

Would it be possible to do this with the stock install of the developer tools? no need to install extra extensions.

So from PHP, you could call something like:

    header('X-Console-Log: Some message');
    header('X-Console-Log: Another message', false);
    header('X-Console-Error: Debug dump', false);

Or perhaps something could be done with JSON and a single header?

    header('X-Console: ' . json_encode(...)); // See note below

I think the developer tools will then just need to look for the header(s), and add it to the console.

Although it will probably be a good idea to also have some kind of filter, so you can see only the JavaScript, network (e.g.404 / CSP type errors), or those from the servers response headers.

---

Note: the output from the json_encode() function might need to be escaped for the header (not sure if a newline character will get out of it).

Paul Irish

unread,
Jan 22, 2013, 2:10:10 PM1/22/13
to Craig Francis, Google Chrome Developer Tools
Hi Craig,

Right now we don't have anything to help with this. I think the best solution is to use an extensions like PHP Console that can do the header->console work. Either that or one could author a more generic extension for this. 

Paul

craig....@gmail.com

unread,
Jan 23, 2013, 7:46:34 AM1/23/13
to google-chrome-...@googlegroups.com, Craig Francis
On Tuesday, 22 January 2013 19:10:10 UTC, Paul Irish wrote:
Right now we don't have anything to help with this. I think the best solution is to use an extensions like PHP Console that can do the header->console work. Either that or one could author a more generic extension for this. 


Yep, thought that might be the case, but was wondering if this could be a feature request, so we could have some kind of standard (like how console.log became a standard in the JS world).

Must admit, I'm not sure where you can do feature requests for Chrome Dev Tools... can only find the generic area for raising issues:

craig....@gmail.com

unread,
Jan 23, 2013, 7:59:05 AM1/23/13
to google-chrome-...@googlegroups.com, Craig Francis
On 23 Jan 2013, at 12:50, Ivan Žužak wrote:
That's the right place for submitting feature requests. Click "New issue" and you will be taken to a wizard process which allows you to specify that the issue is related to DevTools (step 2 of the wizard process).



Thanks Ivan,

The request has been added:


Ivan Žužak

unread,
Jan 23, 2013, 7:50:16 AM1/23/13
to craig....@gmail.com, google-chrome-...@googlegroups.com
On Wed, Jan 23, 2013 at 1:46 PM, <craig....@gmail.com> wrote:
Must admit, I'm not sure where you can do feature requests for Chrome Dev Tools... can only find the generic area for raising issues:


That's the right place for submitting feature requests. Click "New issue" and you will be taken to a wizard process which allows you to specify that the issue is related to DevTools (step 2 of the wizard process).

Cheers,
Ivan
Reply all
Reply to author
Forward
0 new messages