Skip to content

Support PSR LoggerInterface in database config #68

Description

@roxblnfk

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);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions