mirror of
https://github.com/archtechx/tenancy.git
synced 2026-05-06 16:24:03 +00:00
Preserve filename from central log path in tenant context
This commit is contained in:
parent
9ea3813d28
commit
23ae15a8f1
2 changed files with 44 additions and 1 deletions
|
|
@ -397,3 +397,44 @@ test('slack channel uses correct webhook urls', function () {
|
|||
// Central context, central webhook should be used again
|
||||
$assertWebhook('central-webhook', 'central');
|
||||
});
|
||||
|
||||
test('tenant logs inherit the filename from the central log path config', function () {
|
||||
config([
|
||||
'tenancy.bootstrappers' => [
|
||||
FilesystemTenancyBootstrapper::class,
|
||||
LogTenancyBootstrapper::class,
|
||||
],
|
||||
'logging.channels.stack' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => ['single', 'daily'],
|
||||
],
|
||||
'logging.channels.single.path' => storage_path('logs/custom-name.log'),
|
||||
'logging.channels.daily.path' => storage_path('logs/custom-name.log'),
|
||||
]);
|
||||
|
||||
$tenant = Tenant::create();
|
||||
$today = now()->format('Y-m-d');
|
||||
|
||||
// Central log is located at storage/logs/custom-name.log
|
||||
Log::channel('stack')->info('central');
|
||||
|
||||
expect(file_get_contents(storage_path('logs/custom-name.log')))->toContain('central');
|
||||
expect(file_get_contents(storage_path("logs/custom-name-{$today}.log")))->toContain('central');
|
||||
|
||||
tenancy()->initialize($tenant);
|
||||
|
||||
// Tenant log is located at storage/tenantX/logs/custom-name.log
|
||||
Log::channel('stack')->info($tenant->id);
|
||||
|
||||
// The filename from the central config is preserved in tenant context
|
||||
expect(config('logging.channels.single.path'))->toEndWith('custom-name.log');
|
||||
expect(config('logging.channels.daily.path'))->toEndWith('custom-name.log');
|
||||
|
||||
expect(file_get_contents(storage_path('logs/custom-name.log')))
|
||||
->toContain($tenant->id)
|
||||
->not()->toContain('central');
|
||||
|
||||
expect(file_get_contents(storage_path("logs/custom-name-{$today}.log")))
|
||||
->toContain($tenant->id)
|
||||
->not()->toContain('central');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue