Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PSR LoggerInterface in database config #68

Open
roxblnfk opened this issue Feb 21, 2023 · 0 comments
Open

Support PSR LoggerInterface in database config #68

roxblnfk opened this issue Feb 21, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@roxblnfk
Copy link
Member

roxblnfk commented Feb 21, 2023

It will be better to support a PSR class name in $config['database']['logger']['default']

if ($driver instanceof NamedInterface && isset($this->config['drivers'][$driver->getName()])) {
    $channel = $this->config['drivers'][$driver->getName()];
} else if (isset($this->config['drivers'][$driver::class])) {
    $channel = $this->config['drivers'][$driver::class];
} else if (isset($this->config['default']) && $this->config['default'] !== null) {
    $channel = $this->config['default'];
}

// Here is an example of how to do it
if (\is_subclass_of($channel, LoggerInterface::class)) {
    return $this->container->get($channel);
}

return $this->container->get(LogsInterface::class)->getLogger($channel);
@roxblnfk roxblnfk added the enhancement New feature or request label Feb 21, 2023
@butschster butschster self-assigned this Feb 21, 2023
@butschster butschster added this to the v2.x milestone Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants