Tenant specific logging #406
christopherarter
started this conversation in
Ideas
Replies: 1 comment
-
For my purpose, I've just set the shared the tenant into the logging context like so: class AddLoggingContext implements SwitchTenantTask
{
public function makeCurrent(Tenant $tenant): void
{
Log::shareContext(array_filter([
'tenant' => $tenant->name,
'url' => url()->current(),
]));
}
public function forgetCurrent(): void
{
Log::withoutContext();
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This may be a feature I'm not aware of, but I didn't see it when I searched the docs. We have a use case for knowing which log messages were generated by which tenant. We've created a helper,
tenant_log_info(...)
,tenant_log_error(...)
etc. for each log level. This prefixes the log with the given current tenant. So if the current tenant isFoo
, by callingtenant_log_info('Logging some information here')
we would get:Would this be of use to anyone in the base package itself? A PR for this would likely just be a
helpers
file with some helpers like above. I'd be happy to submit one if others see a use case. It would be a pretty simple wrapper around the existing helpers with a tenant prefix'd.Just an idea :)
Beta Was this translation helpful? Give feedback.
All reactions