Skip to content

Commit 698029e

Browse files
authored
Refactor prepareHandler (#39093)
1 parent 9b0a166 commit 698029e

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/Illuminate/Log/LogManager.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -397,17 +397,13 @@ protected function prepareHandlers(array $handlers)
397397
*/
398398
protected function prepareHandler(HandlerInterface $handler, array $config = [])
399399
{
400-
$isHandlerFormattable = false;
401-
402-
if (Monolog::API === 1) {
403-
$isHandlerFormattable = true;
404-
} elseif (Monolog::API === 2 && $handler instanceof FormattableHandlerInterface) {
405-
$isHandlerFormattable = true;
400+
if (Monolog::API !== 1 && (Monolog::API !== 2 || ! $handler instanceof FormattableHandlerInterface)) {
401+
return $handler;
406402
}
407403

408-
if ($isHandlerFormattable && ! isset($config['formatter'])) {
404+
if (! isset($config['formatter'])) {
409405
$handler->setFormatter($this->formatter());
410-
} elseif ($isHandlerFormattable && $config['formatter'] !== 'default') {
406+
} elseif ($config['formatter'] !== 'default') {
411407
$handler->setFormatter($this->app->make($config['formatter'], $config['formatter_with'] ?? []));
412408
}
413409

0 commit comments

Comments
 (0)