Browse Source

Cleaning up, Fixing #9

2.1.0
Dustin Wilson 1 year ago
parent
commit
83eafab08a
  1. 2
      lib/Catcher/Handler.php
  2. 15
      lib/Catcher/PlainTextHandler.php
  3. 2
      lib/Catcher/ThrowableController.php

2
lib/Catcher/Handler.php

@ -26,7 +26,7 @@ abstract class Handler {
/**
* Array of HandlerOutputs the handler creates
*
* @var HandlerOutput[]
* @var array[]
*/
protected array $outputBuffer = [];

15
lib/Catcher/PlainTextHandler.php

@ -47,34 +47,35 @@ class PlainTextHandler extends Handler {
}
protected function log(\Throwable $throwable, string $message): void {
$context = [ 'exception' => $throwable ];
if ($throwable instanceof \Error) {
switch ($throwable->getCode()) {
case \E_NOTICE:
case \E_USER_NOTICE:
case \E_STRICT:
$this->_logger->notice($message);
$this->_logger->notice($message, $context);
break;
case \E_WARNING:
case \E_COMPILE_WARNING:
case \E_USER_WARNING:
case \E_DEPRECATED:
case \E_USER_DEPRECATED:
$this->_logger->warning($message);
$this->_logger->warning($message, $context);
break;
case \E_RECOVERABLE_ERROR:
$this->_logger->error($message);
$this->_logger->error($message, $context);
break;
case \E_PARSE:
case \E_CORE_ERROR:
case \E_COMPILE_ERROR:
$this->_logger->alert($message);
$this->_logger->alert($message, $context);
break;
default: $this->_logger->critical($message);
default: $this->_logger->critical($message, $context);
}
} elseif ($throwable instanceof \Exception && ($throwable instanceof \PharException || $throwable instanceof \RuntimeException)) {
$this->_logger->alert($message);
$this->_logger->alert($message, $context);
} else {
$this->_logger->critical($message);
$this->_logger->critical($message, $context);
}
}

2
lib/Catcher/ThrowableController.php

@ -101,7 +101,7 @@ class ThrowableController {
!in_array($this->throwable->getCode(), [ E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING ]) ||
!extension_loaded('xdebug') ||
!function_exists('xdebug_info') ||
sizeof(\xdebug_info('mode')) === 0
sizeof(xdebug_info('mode')) === 0
) {
$frames = $this->throwable->getTrace();
} else {

Loading…
Cancel
Save