@@ -320,30 +320,27 @@ protected function createErrorlogDriver(array $config)
320320 }
321321
322322 /**
323- * Create an instance of any handler available in Monolog from configuration .
323+ * Create an instance of any handler available in Monolog.
324324 *
325- * @param array $config
326- * @return \Monolog\Logger
325+ * @param array $config
326+ * @return \Psr\Log\LoggerInterface
327+ *
328+ * @throws \InvalidArgumentException
327329 * @throws \Illuminate\Contracts\Container\BindingResolutionException
328330 */
329331 protected function createMonologDriver (array $ config )
330332 {
331- if (isset ($ config ['handler_type ' ])) {
332- $ handlerClass = 'Monolog\Handler \\' .ucfirst ($ config ['handler_type ' ]).'Handler ' ;
333- } elseif (isset ($ config ['handler_class ' ])) {
334- $ handlerClass = $ config ['handler_class ' ];
335- } else {
336- throw new InvalidArgumentException ('"handler_type" or "handler_class" is required for the monolog driver ' );
333+ if (! is_a ($ config ['handler ' ], HandlerInterface::class, true )) {
334+ throw new InvalidArgumentException (
335+ $ config ['handler ' ].' must be an instance of ' .HandlerInterface::class
336+ );
337337 }
338338
339- if (! is_a ( $ handlerClass , HandlerInterface::class, true )) {
340- throw new InvalidArgumentException ( $ handlerClass . ' must be an instance of ' .HandlerInterface::class);
341- }
339+ $ handlers = [ $ this -> prepareHandler (
340+ $ this -> app -> make ( $ config [ ' handler ' ], $ config [ ' with ' ] ?? [])
341+ )];
342342
343- return new Monolog (
344- $ this ->parseChannel ($ config ),
345- [$ this ->prepareHandler ($ this ->app ->make ($ handlerClass , $ config ['handler_params ' ] ?? []))]
346- );
343+ return new Monolog ($ this ->parseChannel ($ config ), $ handlers );
347344 }
348345
349346 /**
0 commit comments