Skip to content

Commit

Permalink
Simplified creation of handler instance (use makeWith() instead of co…
Browse files Browse the repository at this point in the history
…ntext parameter binding)
  • Loading branch information
ralphschindler committed Mar 13, 2018
1 parent 66d52e6 commit 6fce7fd
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/Illuminate/Log/LogManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ protected function createErrorlogDriver(array $config)
}

/**
* Create an instance of any handler provided by Monolog provided via configuration.
* Create an instance of any handler available in Monolog from configuration.
*
* @param array $config
* @return \Monolog\Logger
Expand All @@ -340,17 +340,10 @@ protected function createMonologDriver(array $config)
throw new InvalidArgumentException($handlerClass.' must be an instance of '.HandlerInterface::class);
}

$container = $this->app;

if (isset($config['handler_params'])) {
// clone app so that contextual bindings are not persisted
$container = clone $this->app;
foreach ($config['handler_params'] as $name => $value) {
$container->addContextualBinding($handlerClass, '$'.$name, $value);
}
}

return new Monolog($this->parseChannel($config), [$this->prepareHandler($container->build($handlerClass))]);
return new Monolog(
$this->parseChannel($config),
[$this->prepareHandler($this->app->make($handlerClass, $config['handler_params'] ?? []))]
);
}

/**
Expand Down

0 comments on commit 6fce7fd

Please sign in to comment.