Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChromePhp stops logging during code block but code block continues to execute #32

Open
jasoncatudal opened this issue Aug 21, 2013 · 1 comment

Comments

@jasoncatudal
Copy link

Hi there,

Here's my code. The third log command doesn't appear nor any further log commands, but the code executes to the bottom of the block. In other words, the last echo appears but not the Chrome Logger logs in between. What am I missing?

log('Hello console!'); $mysqli = new mysqli("localhost", "username", "password", "database", 8889); $log->log("Mysqli created"); if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: " . $mysqli->connect_error; } echo $mysqli->host_info . "\n"; $log->log("after host info"); ChromePhp::log("setup"); $query = "SELECT \* FROM products"; ChromePhp::log($query); echo $query; ?>

EDIT: I should point out that I realize this might be hard to test. When I run this code on my machine, the database connection doesn't trigger any errors so it looks like that is good. However, the query execution doesn't seem to be working right. I don't know why (which is why I'm debugging!). If I ever figure it out, I'll update this post so we can try to figure out what's going on here with ChromePhp and why it doesn't log the lines before the query execution. Also, this is using MAMP on Mac OS X in case you would like to connect to your own db to try it.

@mattzuba
Copy link

The 'problem' is your code, not ChromePhp/ChromeLogger. ChromeLogger depends on HTTP headers to do it's work. The minute you do an 'echo' statement, headers send, so any ChromePhp calls you make after output has started will not make it to chrome.

You can try starting output buffering at the top of your code (ob_start()) and that may solve your problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants