From c758eab5ca89554f5ea3a7c1a30aa38d67563d03 Mon Sep 17 00:00:00 2001 From: Daniel Neykov Date: Sat, 30 Jan 2021 17:25:38 +0200 Subject: [PATCH] TenantAwareLogger improvement Do not hardcode `tenancy/tenants` folder for the logs because if you change tenancy storage folder logs will be created in default directory. --- src/Logging/TenantAwareLogger.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Logging/TenantAwareLogger.php b/src/Logging/TenantAwareLogger.php index a4577ea1..afcd3090 100644 --- a/src/Logging/TenantAwareLogger.php +++ b/src/Logging/TenantAwareLogger.php @@ -32,9 +32,11 @@ public function __invoke(array $config) $log = new Logger('tenant'); $level = $log->toMonologLevel($config['level'] ?: 'debug'); $tenantDirectory = app(Directory::class); - $directoryPath = $tenantDirectory->getWebsite() ? 'app/tenancy/tenants/' . $tenantDirectory->path() : null; + $tenantDisk = config('tenancy.website.disk') ?: 'tenancy-default'; + $directoryPath = $tenantDirectory->getWebsite() ? + config('filesystems.disks.' . $tenantDisk . '.root') . '/' . $tenantDirectory->path() : null; - $logPath = storage_path($directoryPath . 'logs/' . $config['level'] . '_' . Carbon::now()->toDateString() . '.log'); + $logPath = $directoryPath . 'logs/' . $config['level'] . '_' . Carbon::now()->toDateString() . '.log'; $log->pushHandler(new StreamHandler($logPath, $level, false)); return $log;