Skip to content

Commit d499617

Browse files
committed
formatting
1 parent 614f4f9 commit d499617

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

src/Illuminate/Log/LogManager.php

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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
/**

tests/Log/LogManagerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public function testLogManagerCreatesConfiguredMonologHandler()
2828
$config->set('logging.channels.nonbubblingstream', [
2929
'driver' => 'monolog',
3030
'name' => 'foobar',
31-
'handler_type' => 'stream',
32-
'handler_params' => [
31+
'handler' => StreamHandler::class,
32+
'with' => [
3333
'stream' => 'php://stderr',
3434
'level' => Monolog::NOTICE,
3535
'bubble' => false,
@@ -56,8 +56,8 @@ public function testLogManagerCreatesConfiguredMonologHandler()
5656
$config->set('logging.channels.logentries', [
5757
'driver' => 'monolog',
5858
'name' => 'le',
59-
'handler_type' => 'LogEntries',
60-
'handler_params' => [
59+
'handler' => LogEntriesHandler::class,
60+
'with' => [
6161
'token' => '123456789',
6262
],
6363
]);

0 commit comments

Comments
 (0)