diff --git a/Kiri.php b/Kiri.php index 09d7d4ca..d1ece166 100644 --- a/Kiri.php +++ b/Kiri.php @@ -124,6 +124,7 @@ class Kiri /** * @return LoggerInterface + * @throws ReflectionException */ public static function getLogger(): LoggerInterface { diff --git a/kiri-engine/Abstracts/Component.php b/kiri-engine/Abstracts/Component.php index e378bec1..9f3dd274 100644 --- a/kiri-engine/Abstracts/Component.php +++ b/kiri-engine/Abstracts/Component.php @@ -23,9 +23,6 @@ class Component implements Configure { - protected ?StdoutLoggerInterface $logger = null; - - /** * BaseAbstract constructor. * diff --git a/kiri-engine/Error/ErrorHandler.php b/kiri-engine/Error/ErrorHandler.php index b46200a9..fc882423 100644 --- a/kiri-engine/Error/ErrorHandler.php +++ b/kiri-engine/Error/ErrorHandler.php @@ -148,7 +148,7 @@ class ErrorHandler extends Component implements ErrorInterface $data = Json::jsonFail($error[1], 500, $path); - $this->logger->error('On error handler', [$data]); + \Kiri::getLogger()->error('On error handler', [$data]); $this->dispatch->dispatch(new Kiri\Events\OnSystemError()); diff --git a/kiri-engine/Pool/Connection.php b/kiri-engine/Pool/Connection.php index 166841f7..0e938806 100644 --- a/kiri-engine/Pool/Connection.php +++ b/kiri-engine/Pool/Connection.php @@ -172,7 +172,7 @@ class Connection extends Component $result = true; } } catch (Error|Throwable $exception) { - $result = $this->logger->addError($exception, 'mysql'); + $result = \Kiri::getLogger()->addError($exception, 'mysql'); } finally { return $result; } diff --git a/kiri-engine/Redis/Redis.php b/kiri-engine/Redis/Redis.php index 7d0d5b19..d2e0a53e 100644 --- a/kiri-engine/Redis/Redis.php +++ b/kiri-engine/Redis/Redis.php @@ -194,7 +194,7 @@ SCRIPT; try { $response = $client->{$name}(...$arguments); } catch (\Throwable $throwable) { - $response = $this->logger->addError($throwable->getMessage()); + $response = \Kiri::getLogger()->addError($throwable->getMessage()); } finally { $pool = $this->container->get(Pool::class); $pool->push($this->host, $client);