88namespace Leaf \Exception ;
99
1010use InvalidArgumentException ;
11- use Throwable ;
1211use Leaf \Exceptions \ErrorException ;
1312use Leaf \Exceptions \Inspector ;
1413use Leaf \Exception \Handler \CallbackHandler ;
1514use Leaf \Exception \Handler \Handler ;
1615use Leaf \Exception \Handler \HandlerInterface ;
1716use Leaf \Exception \Util \Misc ;
1817use Leaf \Exception \Util \SystemFacade ;
18+ use Throwable ;
1919
2020final 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