Update logging for Laravel 5.6 #1221

This commit is contained in:
James Cole 2018-03-07 20:47:39 +01:00
parent 49d0ed0c1b
commit 47c9f1e9b8
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
7 changed files with 112 additions and 32 deletions

View File

@ -17,6 +17,9 @@ APP_KEY=${FF_APP_KEY}
APP_URL=${APP_URL}
TRUSTED_PROXIES=${TRUSTED_PROXIES}
# The log channel defines where your log entries go to.
LOG_CHANNEL=${LOG_CHANNEL}
# Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III
# If you use SQLite, set connection to `sqlite` and remove the database, username and password settings.
DB_CONNECTION=mysql

View File

@ -21,6 +21,9 @@ TZ=UTC
APP_URL=http://localhost
TRUSTED_PROXIES=
# The log channel defines where your log entries go to.
LOG_CHANNEL=daily
# Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III
# If you use SQLite, set connection to `sqlite` and remove the database, username and password settings.
DB_CONNECTION=mysql

View File

@ -21,6 +21,9 @@ TZ=UTC
APP_URL=http://localhost
TRUSTED_PROXIES=
# The log channel defines where your log entries go to.
LOG_CHANNEL=syslog
# Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III
# If you use SQLite, set connection to `sqlite` and remove the database, username and password settings.
DB_CONNECTION=pgsql

View File

@ -21,6 +21,9 @@ TZ=UTC
APP_URL=http://localhost
TRUSTED_PROXIES=
# The log channel defines where your log entries go to.
LOG_CHANNEL=syslog
# Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III
# If you use SQLite, set connection to `sqlite` and remove the database, username and password settings.
DB_CONNECTION=mysql

View File

@ -28,6 +28,9 @@ REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
# The log channel defines where your log entries go to.
LOG_CHANNEL=dailytest
MAIL_DRIVER=log
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525

View File

@ -70,38 +70,6 @@ $app->singleton(
FireflyIII\Exceptions\Handler::class
);
///* Overrule logging if not Sandstorm */
//if (!(env('IS_SANDSTORM') === true)) {
// $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);
// }
// );
//}
/*
|--------------------------------------------------------------------------
| Return The Application

97
config/logging.php Normal file
View File

@ -0,0 +1,97 @@
<?php
/**
* logging.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
*/
'default' => env('LOG_CHANNEL', 'daily'),
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Drivers: "single", "daily", "slack", "syslog",
| "errorlog", "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/ff3-' . php_sapi_name() . '-.log'),
'level' => env('APP_LOG_LEVEL', 'info'),
'days' => 7,
],
'dailytest' => [
'driver' => 'daily',
'path' => storage_path('logs/test-ff3-' . php_sapi_name() . '-.log'),
'level' => env('APP_LOG_LEVEL', 'info'),
'days' => 7,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => 'critical',
],
'syslog' => [
'driver' => 'syslog',
'level' => env('APP_LOG_LEVEL', 'info'),
],
'errorlog' => [
'driver' => 'errorlog',
'level' => env('APP_LOG_LEVEL', 'info'),
],
],
];