Add debug option

This commit is contained in:
Frédéric Guillot
2014-12-31 12:56:29 -05:00
parent 772804add8
commit 198f8d6a8e
8 changed files with 23 additions and 10 deletions

View File

@@ -13,6 +13,7 @@ use Pimple\Container;
* @property \Model\Acl $acl
* @property \Model\LastLogin $lastLogin
* @property \Model\User $user
* @property \Model\UserSession $userSession
*/
abstract class Base
{

View File

@@ -100,9 +100,11 @@ abstract class Base
*/
public function __destruct()
{
// foreach ($this->container['db']->getLogMessages() as $message) {
// $this->container['logger']->addDebug($message);
// }
if (DEBUG) {
foreach ($this->container['db']->getLogMessages() as $message) {
$this->container['logger']->addDebug($message);
}
}
}
/**

View File

@@ -574,7 +574,7 @@ class Project extends Base
*/
public function create(array $values = array(), array $errors = array())
{
$is_private = $this->request->getIntegerParam('private', ! $this->userSession->isAdmin());
$is_private = $this->request->getIntegerParam('private', $this->userSession->isAdmin() ? 0 : 1);
$this->response->html($this->template->layout('project/new', array(
'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),

View File

@@ -11,6 +11,7 @@ class DatabaseProvider implements ServiceProviderInterface
public function register(Container $container)
{
$container['db'] = $this->getInstance();
$container['db']->stopwatch = DEBUG;
}
/**

View File

@@ -13,8 +13,11 @@ class LoggingProvider implements ServiceProviderInterface
public function register(Container $container)
{
$logger = new Logger('app');
$logger->pushHandler(new StreamHandler(__DIR__.'/../../data/debug.log', Logger::DEBUG));
$logger->pushHandler(new SyslogHandler('kanboard', LOG_USER, Logger::DEBUG));
$logger->pushHandler(new SyslogHandler('kanboard', LOG_USER, Logger::INFO));
if (DEBUG) {
$logger->pushHandler(new StreamHandler(__DIR__.'/../../data/debug.log', Logger::DEBUG));
}
$container['logger'] = $logger;
}

View File

@@ -1,5 +1,8 @@
<?php
// Enable/disable debug
defined('DEBUG') or define('DEBUG', false);
// Application version
defined('APP_VERSION') or define('APP_VERSION', 'master');