Skip to content

Firefly III: a personal finances manager

Some log fine tuning.

James Cole811664452639
diff --git a/.env.example b/.env.example
index 337ec714db..20f71dc696 100755
--- a/.env.example
+++ b/.env.example
@@ -1,7 +1,7 @@
APP_ENV=production
APP_DEBUG=false
APP_KEY=SomeRandomStringOf32CharsExactly
-
+LOG_LEVEL=warning
DB_CONNECTION=mysql
DB_HOST=localhost
diff --git a/.env.testing b/.env.testing
index a7c8505a17..852745ab42 100755
--- a/.env.testing
+++ b/.env.testing
@@ -1,7 +1,7 @@
APP_ENV=testing
APP_DEBUG=true
APP_KEY=SomeRandomStringOf32CharsExactly
-
+LOG_LEVEL=debug
DB_CONNECTION=sqlite
DB_HOST=localhost
diff --git a/app/Bootstrap/ConfigureLogging.php b/app/Bootstrap/ConfigureLogging.php
new file mode 100644
index 0000000000..0f9b9d4d65
--- /dev/null
+++ b/app/Bootstrap/ConfigureLogging.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * ConfigureLogging.php
+ * Copyright (C) 2016 [email protected]
+ *
+ * This software may be modified and distributed under the terms
+ * of the MIT license. See the LICENSE file for details.
+ */
+
+namespace FireflyIII\Bootstrap;
+
+use Illuminate\Log\Writer;
+use Illuminate\Contracts\Foundation\Application;
+use Illuminate\Foundation\Bootstrap\ConfigureLogging as IlluminateConfigureLogging;
+
+/**
+ * Class ConfigureLogging
+ *
+ * @package FireflyIII\Bootstrap
+ */
+class ConfigureLogging extends IlluminateConfigureLogging
+{
+ /**
+ * @param Application $app
+ * @param Writer $log
+ */
+ protected function configureSingleHandler(Application $app, Writer $log)
+ {
+ $log->useFiles($app->storagePath().'/logs/firefly-iii.log');
+ }
+
+ /**
+ * @param Application $app
+ * @param Writer $log
+ */
+ protected function configureDailyHandler(Application $app, Writer $log)
+ {
+ $log->useDailyFiles(
+ $app->storagePath().'/logs/firefly-iii.log',
+ $app->make('config')->get('app.log_max_files', 5)
+ );
+ }
+}
\ No newline at end of file
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index d077819913..4540fcc9d8 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -22,6 +22,25 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
*/
class Kernel extends ConsoleKernel
{
+
+ /**
+ * The bootstrap classes for the application.
+ *
+ * This needs to be for with the next upgrade.
+ *
+ * @var array
+ */
+ protected $bootstrappers = [
+ 'Illuminate\Foundation\Bootstrap\DetectEnvironment',
+ 'Illuminate\Foundation\Bootstrap\LoadConfiguration',
+ 'FireflyIII\Bootstrap\ConfigureLogging',
+ 'Illuminate\Foundation\Bootstrap\HandleExceptions',
+ 'Illuminate\Foundation\Bootstrap\RegisterFacades',
+ 'Illuminate\Foundation\Bootstrap\SetRequestForConsole',
+ 'Illuminate\Foundation\Bootstrap\RegisterProviders',
+ 'Illuminate\Foundation\Bootstrap\BootProviders',
+ ];
+
/**
* The Artisan commands provided by your application.
*
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
index 064d21119f..c7d8e2bb63 100644
--- a/app/Http/Kernel.php
+++ b/app/Http/Kernel.php
@@ -29,6 +29,23 @@ use Illuminate\View\Middleware\ShareErrorsFromSession;
*/
class Kernel extends HttpKernel
{
+ /**
+ * The bootstrap classes for the application.
+ *
+ * Next upgrade should verify these are all here.
+ *
+ * @var array
+ */
+ protected $bootstrappers = [
+ 'Illuminate\Foundation\Bootstrap\DetectEnvironment',
+ 'Illuminate\Foundation\Bootstrap\LoadConfiguration',
+ 'FireflyIII\Bootstrap\ConfigureLogging',
+ 'Illuminate\Foundation\Bootstrap\HandleExceptions',
+ 'Illuminate\Foundation\Bootstrap\RegisterFacades',
+ 'Illuminate\Foundation\Bootstrap\RegisterProviders',
+ 'Illuminate\Foundation\Bootstrap\BootProviders',
+ ];
+
/**
* The application's global HTTP middleware stack.
*
diff --git a/app/Jobs/MailError.php b/app/Jobs/MailError.php
index 09b6af6cca..ff3298aa28 100644
--- a/app/Jobs/MailError.php
+++ b/app/Jobs/MailError.php
@@ -38,7 +38,6 @@ class MailError extends Job implements ShouldQueue
* @param string $ipAddress
* @param array $exceptionData
*
- * @internal param array $exception
*/
public function __construct(User $user, string $destination, string $ipAddress, array $exceptionData)
{
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index e370e91496..4475d28529 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -4,7 +4,8 @@ declare(strict_types = 1);
namespace FireflyIII\Providers;
use Illuminate\Support\ServiceProvider;
-
+use Log;
+use Config;
/**
* Class AppServiceProvider
*
@@ -29,6 +30,10 @@ class AppServiceProvider extends ServiceProvider
*/
public function register()
{
- //
+ // make sure the logger doesn't log everything when it doesn't need to.
+ $monolog = Log::getMonolog();
+ foreach ($monolog->getHandlers() as $handler) {
+ $handler->setLevel(Config::get('app.log-level'));
+ }
}
}
diff --git a/config/app.php b/config/app.php
index 7efa1d2687..8ba2732c0d 100644
--- a/config/app.php
+++ b/config/app.php
@@ -108,7 +108,8 @@ return [
|
*/
- 'log' => env('APP_LOG', 'daily'),
+ 'log' => env('APP_LOG', 'daily'),
+ 'log-level' => env('LOG_LEVEL', 'info'),
/*
|--------------------------------------------------------------------------