Improved code in LoggerFactory

This commit is contained in:
Alejandro Celaya 2018-11-17 07:31:51 +01:00
parent d945e0c31b
commit 1363194909

View file

@ -29,10 +29,10 @@ class LoggerFactory implements FactoryInterface
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$config = $container->has('config') ? $container->get('config') : [];
Cascade::fileConfig(isset($config['logger']) ? $config['logger'] : ['loggers' => []]);
Cascade::fileConfig($config['logger'] ?? ['loggers' => []]);
// Compose requested logger name
$loggerName = isset($options) & isset($options['logger_name']) ? $options['logger_name'] : 'Logger';
$loggerName = $options['logger_name'] ?? 'Logger';
$nameParts = explode('_', $requestedName);
if (count($nameParts) > 1) {
$loggerName = $nameParts[1];