Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 14, 2018
1 parent 614f4f9 commit d499617
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
29 changes: 13 additions & 16 deletions src/Illuminate/Log/LogManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,30 +320,27 @@ protected function createErrorlogDriver(array $config)
}

/**
* Create an instance of any handler available in Monolog from configuration.
* Create an instance of any handler available in Monolog.
*
* @param array $config
* @return \Monolog\Logger
* @param array $config
* @return \Psr\Log\LoggerInterface
*
* @throws \InvalidArgumentException
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
protected function createMonologDriver(array $config)
{
if (isset($config['handler_type'])) {
$handlerClass = 'Monolog\Handler\\'.ucfirst($config['handler_type']).'Handler';
} elseif (isset($config['handler_class'])) {
$handlerClass = $config['handler_class'];
} else {
throw new InvalidArgumentException('"handler_type" or "handler_class" is required for the monolog driver');
if (! is_a($config['handler'], HandlerInterface::class, true)) {
throw new InvalidArgumentException(
$config['handler'].' must be an instance of '.HandlerInterface::class
);
}

if (! is_a($handlerClass, HandlerInterface::class, true)) {
throw new InvalidArgumentException($handlerClass.' must be an instance of '.HandlerInterface::class);
}
$handlers = [$this->prepareHandler(
$this->app->make($config['handler'], $config['with'] ?? [])
)];

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

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/Log/LogManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public function testLogManagerCreatesConfiguredMonologHandler()
$config->set('logging.channels.nonbubblingstream', [
'driver' => 'monolog',
'name' => 'foobar',
'handler_type' => 'stream',
'handler_params' => [
'handler' => StreamHandler::class,
'with' => [
'stream' => 'php://stderr',
'level' => Monolog::NOTICE,
'bubble' => false,
Expand All @@ -56,8 +56,8 @@ public function testLogManagerCreatesConfiguredMonologHandler()
$config->set('logging.channels.logentries', [
'driver' => 'monolog',
'name' => 'le',
'handler_type' => 'LogEntries',
'handler_params' => [
'handler' => LogEntriesHandler::class,
'with' => [
'token' => '123456789',
],
]);
Expand Down

0 comments on commit d499617

Please sign in to comment.