mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 20:16:22 +00:00
Expand logging
This commit is contained in:
@@ -24,13 +24,28 @@ declare(strict_types=1);
|
||||
use FireflyIII\Support\Logging\AuditLogger;
|
||||
use Monolog\Handler\SyslogUdpHandler;
|
||||
|
||||
// to correctly redirect audit channel messages the
|
||||
// options for the audit stack are set here, but can be overruled
|
||||
// from an environment variable:
|
||||
$auditChannels = ['audit_daily', 'audit_stdout'];
|
||||
$option = envNonEmpty('AUDIT_LOG_CHANNEL', '');
|
||||
if ('' !== (string)$option) {
|
||||
$auditChannels = [$option];
|
||||
// standard config for both log things:
|
||||
$defaultChannels = ['daily', 'stdout'];
|
||||
$auditChannels = ['audit_daily', 'audit_stdout'];
|
||||
|
||||
|
||||
// validChannels is missing 'stack' because we already check for that one.
|
||||
$validChannels = ['single', 'papertrail', 'stdout', 'daily', 'syslog', 'errorlog'];
|
||||
$validAuditChannels = ['audit_papertrail', 'audit_stdout', 'audit_stdout', 'audit_daily', 'audit_syslog', 'audit_errorlog'];
|
||||
|
||||
// which settings did the user set, if any?
|
||||
$defaultLogChannel = (string)envNonEmpty('LOG_CHANNEL', 'stack');
|
||||
$auditLogChannel = (string)envNonEmpty('AUDIT_LOG_CHANNEL', '');
|
||||
|
||||
if ('stack' === $defaultLogChannel) {
|
||||
$defaultChannels = ['daily', 'stdout'];
|
||||
}
|
||||
if (in_array($defaultLogChannel, $validChannels, true)) {
|
||||
$defaultChannels = [$defaultLogChannel];
|
||||
}
|
||||
|
||||
if (in_array($auditLogChannel, $validAuditChannels, true)) {
|
||||
$auditChannels = [$auditLogChannel];
|
||||
}
|
||||
|
||||
return [
|
||||
@@ -62,16 +77,27 @@ return [
|
||||
*/
|
||||
|
||||
'channels' => [
|
||||
// default channels for 'stack' and 'audit' logs are stdout and daily logs.
|
||||
'stack' => [
|
||||
/*
|
||||
* 'stack' and 'audit' are the two "generic" channels that
|
||||
* are valid destinations for logs.
|
||||
*/
|
||||
'stack' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => ['daily', 'stdout'],
|
||||
'channels' => $defaultChannels,
|
||||
],
|
||||
'audit' => [
|
||||
'audit' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => $auditChannels,
|
||||
],
|
||||
'papertrail' => [
|
||||
/*
|
||||
* There are 6 valid destinations for the normal logs, listed below:
|
||||
*/
|
||||
'single' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => envNonEmpty('APP_LOG_LEVEL', 'info'),
|
||||
],
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => envNonEmpty('APP_LOG_LEVEL', 'info'),
|
||||
'handler' => SyslogUdpHandler::class,
|
||||
@@ -80,55 +106,65 @@ return [
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
],
|
||||
|
||||
// single laravel log file:
|
||||
'single' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => envNonEmpty('APP_LOG_LEVEL', 'info'),
|
||||
],
|
||||
|
||||
// stdout, used in stack 'stack' by default:
|
||||
'stdout' => [
|
||||
'stdout' => [
|
||||
'driver' => 'single',
|
||||
'path' => 'php://stdout',
|
||||
'level' => envNonEmpty('APP_LOG_LEVEL', 'info'),
|
||||
],
|
||||
|
||||
// daily, used in stack 'stack' by default:
|
||||
'daily' => [
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/ff3-' . PHP_SAPI . '.log'),
|
||||
'level' => envNonEmpty('APP_LOG_LEVEL', 'info'),
|
||||
'days' => 7,
|
||||
],
|
||||
'syslog' => [
|
||||
'driver' => 'syslog',
|
||||
'level' => envNonEmpty('APP_LOG_LEVEL', 'info'),
|
||||
],
|
||||
'errorlog' => [
|
||||
'driver' => 'errorlog',
|
||||
'level' => envNonEmpty('APP_LOG_LEVEL', 'info'),
|
||||
],
|
||||
|
||||
// the audit log destinations:
|
||||
'audit_daily' => [
|
||||
/*
|
||||
* There are 5 valid destinations for the audit logs, listed below.
|
||||
* The only one missing is "single".
|
||||
*/
|
||||
'audit_papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => envNonEmpty('AUDIT_LOG_LEVEL', 'info'),
|
||||
'handler' => SyslogUdpHandler::class,
|
||||
'tap' => [AuditLogger::class],
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_HOST'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
],
|
||||
'audit_stdout' => [
|
||||
'driver' => 'single',
|
||||
'path' => 'php://stdout',
|
||||
'tap' => [AuditLogger::class],
|
||||
'level' => envNonEmpty('AUDIT_LOG_LEVEL', 'info'),
|
||||
],
|
||||
'audit_daily' => [
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/ff3-audit.log'),
|
||||
'tap' => [AuditLogger::class],
|
||||
'level' => envNonEmpty('AUDIT_LOG_LEVEL', 'info'),
|
||||
'days' => 90,
|
||||
],
|
||||
'audit_stdout' => [
|
||||
'driver' => 'single',
|
||||
'path' => 'php://stdout',
|
||||
'audit_syslog' => [
|
||||
'driver' => 'syslog',
|
||||
'tap' => [AuditLogger::class],
|
||||
'level' => envNonEmpty('AUDIT_LOG_LEVEL', 'info'),
|
||||
],
|
||||
'audit_errorlog' => [
|
||||
'driver' => 'errorlog',
|
||||
'tap' => [AuditLogger::class],
|
||||
'level' => envNonEmpty('AUDIT_LOG_LEVEL', 'info'),
|
||||
],
|
||||
|
||||
// syslog destination
|
||||
'syslog' => [
|
||||
'driver' => 'syslog',
|
||||
'level' => envNonEmpty('APP_LOG_LEVEL', 'info'),
|
||||
],
|
||||
|
||||
// errorlog destination
|
||||
'errorlog' => [
|
||||
'driver' => 'errorlog',
|
||||
'level' => envNonEmpty('APP_LOG_LEVEL', 'info'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
Reference in New Issue
Block a user