Skip to content

Commit

Permalink
[11.x] Add Exceptions\Handler::mapLogLevel(...) so the logic can be e…
Browse files Browse the repository at this point in the history
…asily overridden (#52666)

* [11.x] Add Exceptions\Handler::mapLogLevel so the logic can be easily overridden

* formatting

* formatting

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
taka-oyama and taylorotwell authored Sep 6, 2024
1 parent 2714be7 commit bb670ae
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/Illuminate/Foundation/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,7 @@ protected function reportThrowable(Throwable $e): void
throw $e;
}

$level = Arr::first(
$this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR
);
$level = $this->mapLogLevel($e);

$context = $this->buildExceptionContext($e);

Expand Down Expand Up @@ -1047,6 +1045,19 @@ protected function isHttpException(Throwable $e)
return $e instanceof HttpExceptionInterface;
}

/**
* Map the exception to a log level.
*
* @param \Throwable $e
* @return \Psr\Log\LogLevel::*
*/
protected function mapLogLevel(Throwable $e)
{
return Arr::first(
$this->levels, fn ($level, $type) => $e instanceof $type, LogLevel::ERROR
);
}

/**
* Create a new logger instance.
*
Expand Down

0 comments on commit bb670ae

Please sign in to comment.