getgrav / grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony
https://getgrav.org
MIT License
14.59k stars 1.41k forks source link

Debugger in development mode #31

Closed escopecz closed 10 years ago

escopecz commented 10 years ago

Hi,

I'd like to get rid of Tracy bar at production. But it is hard-coded at index.php that debugger is in development mode regardless the configuration:

https://github.com/getgrav/grav/blob/master/index.php

Debugger::enable(Debugger::DEVELOPMENT, is_dir(LOG_DIR) ? LOG_DIR : null);

I can see that at develop branch it is hard-coded the opposite way:

https://github.com/getgrav/grav/blob/develop/index.php

'debugger' => new Debugger(Debugger::PRODUCTION)

I'd suggest to use

Debugger::DETECT

This will use development mode on localhost and production mode on public IP. That is what all of us need, isn't it? More info: https://github.com/nette/tracy#production-mode-and-error-logging

I wanted to implement it and make a pull request, but I can't make develop branch working on my localhost. It seems to have missing few classes. That's why I rather write this issue.

Questions:

  1. Is it possible to implement DETECT mode?
  2. When you plan to release new version? Develop and master branch are quite different...
rhukster commented 10 years ago

First, the debug option in the 0.8.0 release was a bug. We accidentally set the mode in such a way that it could not be changed by the configuration setting. In the Development branch the debugger is set initially to the PRODUCTION mode and then toggled to whatever you have configured in the new Debugger class:

https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Debugger.php

This means that your system setting will actually work now. In the meantime you can manually edit the index.php and change DEVELOPMENT to PRODUCTION.

Regarding the update, yes development branch has MANY new additions and we hope to release a 0.9.0 version on monday. I just need to work on the documentation updates required and some information explaining how this may effect current users. Content is not effected, it's mostly in plugins and themes (need to change asset handling).

escopecz commented 10 years ago

Thanks rhukster. Great answer. Looking forward to new version.

I'd add DETECT mode anyway. You see, file based CMS has great advantage that I can use GIT for my content (/user/ folder) and set up post-receive hook to deploy new code to production server. I did that yesterday actually. I'll write an article about it to my new Grav blog. That is main reason why I have chosen Grav in the first place. When I set it up this way, config files will update as well. That's why I need DETECT mode so it will set debug mode automatically.

It requires to add new property to Debugger.php:

const DETECT = TracyDebugger::DETECT;

and turn this mode up if debug option at config file is for example null or empty. Do you think this could appear in future version?

rhukster commented 10 years ago

I've just pushed a commit to use DETECT by default, but you can override if required in the configuration. Should be out in 0.9.0 shortly.

escopecz commented 10 years ago

Wow, awesome! Thanks!

rhukster commented 10 years ago

Should be sorted with 0.9.0 release