@@ -320,30 +320,27 @@ protected function createErrorlogDriver(array $config)
320
320
}
321
321
322
322
/**
323
- * Create an instance of any handler available in Monolog from configuration .
323
+ * Create an instance of any handler available in Monolog.
324
324
*
325
- * @param array $config
326
- * @return \Monolog\Logger
325
+ * @param array $config
326
+ * @return \Psr\Log\LoggerInterface
327
+ *
328
+ * @throws \InvalidArgumentException
327
329
* @throws \Illuminate\Contracts\Container\BindingResolutionException
328
330
*/
329
331
protected function createMonologDriver (array $ config )
330
332
{
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
+ );
337
337
}
338
338
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
+ )];
342
342
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 );
347
344
}
348
345
349
346
/**
0 commit comments