Skip to content

Commit 3429469

Browse files
committed
feat: add logging to dev
1 parent 9c05caa commit 3429469

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/Exception/Run.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
namespace Leaf\Exception;
99

1010
use InvalidArgumentException;
11-
use Throwable;
1211
use Leaf\Exceptions\ErrorException;
1312
use Leaf\Exceptions\Inspector;
1413
use Leaf\Exception\Handler\CallbackHandler;
1514
use Leaf\Exception\Handler\Handler;
1615
use Leaf\Exception\Handler\HandlerInterface;
1716
use Leaf\Exception\Util\Misc;
1817
use Leaf\Exception\Util\SystemFacade;
18+
use Throwable;
1919

2020
final class Run implements RunInterface
2121
{
@@ -27,22 +27,22 @@ final class Run implements RunInterface
2727
/**
2828
* @var bool
2929
*/
30-
private $allowQuit = true;
30+
private $allowQuit = true;
3131

3232
/**
3333
* @var bool
3434
*/
35-
private $sendOutput = true;
35+
private $sendOutput = true;
3636

3737
/**
3838
* @var integer|false
3939
*/
40-
private $sendHttpCode = 500;
40+
private $sendHttpCode = 500;
4141

4242
/**
4343
* @var integer|false
4444
*/
45-
private $sendExitCode = 1;
45+
private $sendExitCode = 1;
4646

4747
/**
4848
* @var HandlerInterface[]
@@ -439,10 +439,10 @@ public function handleException($exception)
439439
*/
440440
public function handleError($level, $message, $file = null, $line = null)
441441
{
442-
if ($level & $this->system->getErrorReportingLevel()) {
442+
if ($level&$this->system->getErrorReportingLevel()) {
443443
foreach ($this->silencedPatterns as $entry) {
444444
$pathMatches = (bool) preg_match($entry["pattern"], $file);
445-
$levelMatches = $level & $entry["levels"];
445+
$levelMatches = $level&$entry["levels"];
446446
if ($pathMatches && $levelMatches) {
447447
// Ignore the error, abort handling
448448
// See https://github.com/filp/whoops/issues/418
@@ -453,6 +453,12 @@ public function handleError($level, $message, $file = null, $line = null)
453453
// XXX we pass $level for the "code" param only for BC reasons.
454454
// see https://github.com/filp/whoops/issues/267
455455
$exception = new ErrorException($message, /*code*/ $level, /*severity*/ $level, $file, $line);
456+
$app = \Leaf\Config::get("app")["instance"];
457+
458+
if ($app && $app->config("log.enabled")) {
459+
$app->logger()->error($exception);
460+
}
461+
456462
if ($this->canThrowExceptions) {
457463
throw $exception;
458464
} else {
@@ -521,7 +527,7 @@ private function resolveHandler($handler)
521527
if (!$handler instanceof HandlerInterface) {
522528
throw new InvalidArgumentException(
523529
"Handler must be a callable, or instance of "
524-
. "Leaf\\Exception\\Handler\\HandlerInterface"
530+
. "Leaf\\Exception\\Handler\\HandlerInterface"
525531
);
526532
}
527533

0 commit comments

Comments
 (0)