From 02492a23ecd30642946715ab95794219a95b1a46 Mon Sep 17 00:00:00 2001 From: KhanhIceTea Date: Sun, 15 May 2016 10:19:43 +0700 Subject: [PATCH] Fix debug and logging --- src/Sifoni/Engine.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Sifoni/Engine.php b/src/Sifoni/Engine.php index 88188df..3cee697 100644 --- a/src/Sifoni/Engine.php +++ b/src/Sifoni/Engine.php @@ -85,6 +85,7 @@ public function bootstrap(array $new_options = array()) { $default_options = array( 'env' => static::ENV_DEV, + 'logging' => true, 'timezone' => 'Asia/Ho_Chi_Minh', // I <3 Vietnam 'web_profiler' => true, 'enabled_http_cache' => false, @@ -105,7 +106,9 @@ public function bootstrap(array $new_options = array()) { $this->app[$key] = $value; } - $this->app['debug'] = ($this->app['env'] != static::ENV_PROD); + if (!isset($this->app['debug'])) { + $this->app['debug'] = ($this->app['env'] != static::ENV_PROD); + } return $this; } @@ -165,9 +168,12 @@ private function registerServices() { ) )); $app->register(new CapsuleServiceProvider(), $app['config.database.parameters']); - $app->register(new MonologServiceProvider(), array( - 'monolog.logfile' => $this->getStoragePath('log') . DS . ($app['debug'] ? 'debug.log' : 'production.log'), - )); + + if ($app['logging']) { + $app->register(new MonologServiceProvider(), array( + 'monolog.logfile' => $this->getStoragePath('log') . DS . ($app['debug'] ? 'debug.log' : 'production.log'), + )); + } if ($app['debug']) { $app->register(new WhoopsServiceProvider()); @@ -178,7 +184,7 @@ private function registerServices() { 'profiler.mount_prefix' => '/_profiler', )); } - } else { + } elseif ($app['logging']) { $app['monolog.level'] = function () { return Logger::ERROR; }; @@ -275,7 +281,7 @@ private function loadRouting() { public function start() { date_default_timezone_set($this->app['timezone']); - + $this->loadConfig('app'); $this->loadConfig('database'); $this->registerServices();