From a660e1c08e39986d91e8d7ad0f220c6c4f61b511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Sun, 16 Apr 2023 02:46:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Kiri.php | 1 + kiri-engine/Abstracts/Component.php | 3 --- kiri-engine/Error/ErrorHandler.php | 2 +- kiri-engine/Pool/Connection.php | 2 +- kiri-engine/Redis/Redis.php | 2 +- 5 files changed, 4 insertions(+), 6 deletions(-) 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);