From 6fce7fd50c773630d7b0aa5d9427b738d65c50fc Mon Sep 17 00:00:00 2001 From: Ralph Schindler Date: Tue, 13 Mar 2018 16:03:13 -0500 Subject: [PATCH] Simplified creation of handler instance (use makeWith() instead of context parameter binding) --- src/Illuminate/Log/LogManager.php | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Illuminate/Log/LogManager.php b/src/Illuminate/Log/LogManager.php index 86a0ebd343fe..1194d78a5149 100644 --- a/src/Illuminate/Log/LogManager.php +++ b/src/Illuminate/Log/LogManager.php @@ -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 @@ -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'] ?? []))] + ); } /**