Skip to content

Commit

Permalink
Fix debug and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhicetea committed May 15, 2016
1 parent 474fbe3 commit 02492a2
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/Sifoni/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}
Expand Down Expand Up @@ -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());
Expand All @@ -178,7 +184,7 @@ private function registerServices() {
'profiler.mount_prefix' => '/_profiler',
));
}
} else {
} elseif ($app['logging']) {
$app['monolog.level'] = function () {
return Logger::ERROR;
};
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 02492a2

Please sign in to comment.