ccampbell / chromephp

class for logging PHP variables to Google Chrome console
http://www.chromelogger.com
1.38k stars 450 forks source link

Setting to turn off backtraces #18

Closed drakej closed 11 years ago

drakej commented 12 years ago

We utilize ChromePHP through an abstraction layer that detects the browser before outputting messages. The problem is that the entry point is always the same from our code into the log method so the backtrace that's appended is useless. I'm hoping you can add an option to simply disable the backtrace functionality as we just add this ourselves.

drakej commented 12 years ago

If you want I can implement the change and push it to you. Not sure what you think about this as an option but it would help us a lot since we have no other way to override this default behavior.

ccampbell commented 11 years ago

Sorry for not getting back to you 8 months ago when you opened this ticket. I don't think this needs to be in the server side library. You can turn off file/line number logging in the extension options. Also it is not wasted space since the library will only send the same backtrace data once.

Interestingly your use case is the reason I added the setting for ChromePhp::BACKTRACE_LEVEL to begin with. It is not documented I guess, but basically it tells ChromePhp how many levels back to go in the backtrace and defaults to 1. This means if you have a wrapper class it will always show as that. If you change the level you can get ChromePHP to send the trace from the previous file.

For example

Controller.php : 25 calls Console.php : 15 calls ChromePhp.php : 153

With backtrace level at the default every log will come in as Console.php : 15

If you change it to 2

ChromePhp::getInstance()->addSetting(ChromePhp::BACKTRACE_LEVEL, 2)

Then your logs will come back as Controller.php: 25 (the place where the call originated)

Hope this helps!