From 16b0264a79d3b342d27fef2c49f1b653cf754362 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 29 Nov 2017 18:10:43 +0100 Subject: [PATCH] =?UTF-8?q?Do=20not=20overrule=20logging=20when=20it?= =?UTF-8?q?=E2=80=99s=20not=20set=20to=20daily.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.heroku | 2 +- bootstrap/app.php | 57 +++++++++++++++++++++++++---------------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/.env.heroku b/.env.heroku index 9a1b10f4c4..6be1f309bc 100644 --- a/.env.heroku +++ b/.env.heroku @@ -2,7 +2,7 @@ APP_ENV=local APP_DEBUG=true APP_NAME=FireflyIII APP_KEY=7ahyYVPVsmxjdhsweWCauGeJfwc92NP2 -APP_LOG=syslog +APP_LOG=errorlog APP_LOG_LEVEL=debug APP_URL=http://localhost TRUSTED_PROXIES= diff --git a/bootstrap/app.php b/bootstrap/app.php index 3517e6246b..5f1bc85f3f 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -21,7 +21,7 @@ bcscale(12); $app = new Illuminate\Foundation\Application( - realpath(__DIR__.'/../') + realpath(__DIR__ . '/../') ); /* @@ -51,33 +51,36 @@ $app->singleton( ); /* Overrule logging */ -$app->configureMonologUsing( - function (Logger $monolog) use ($app) { - $interface = php_sapi_name(); - $path = $app->storagePath() . '/logs/ff3-' . $interface . '.log'; - $level = 'debug'; - if ($app->bound('config')) { - $level = $app->make('config')->get('app.log_level', 'debug'); +if ($app->make('config')->get('app.log') === 'daily') { + $app->configureMonologUsing( + function (Logger $monolog) use ($app) { + + $interface = php_sapi_name(); + $path = $app->storagePath() . '/logs/ff3-' . $interface . '.log'; + $level = 'debug'; + if ($app->bound('config')) { + $level = $app->make('config')->get('app.log_level', 'debug'); + } + $levels = [ + 'debug' => Logger::DEBUG, + 'info' => Logger::INFO, + 'notice' => Logger::NOTICE, + 'warning' => Logger::WARNING, + 'error' => Logger::ERROR, + 'critical' => Logger::CRITICAL, + 'alert' => Logger::ALERT, + 'emergency' => Logger::EMERGENCY, + ]; + + $useLevel = $levels[$level]; + + $formatter = new LineFormatter(null, null, true, true); + $handler = new RotatingFileHandler($path, 5, $useLevel); + $handler->setFormatter($formatter); + $monolog->pushHandler($handler); } - $levels = [ - 'debug' => Logger::DEBUG, - 'info' => Logger::INFO, - 'notice' => Logger::NOTICE, - 'warning' => Logger::WARNING, - 'error' => Logger::ERROR, - 'critical' => Logger::CRITICAL, - 'alert' => Logger::ALERT, - 'emergency' => Logger::EMERGENCY, - ]; - - $useLevel = $levels[$level]; - - $formatter = new LineFormatter(null, null, true, true); - $handler = new RotatingFileHandler($path, 5, $useLevel); - $handler->setFormatter($formatter); - $monolog->pushHandler($handler); - } -); + ); +} /* |--------------------------------------------------------------------------