From c9eab465ea084e33ccce2a3f0f048084a05b1273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Wed, 19 Apr 2023 10:32:55 +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-engine/Abstracts/Logger.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/kiri-engine/Abstracts/Logger.php b/kiri-engine/Abstracts/Logger.php index 1912467d..8917943a 100644 --- a/kiri-engine/Abstracts/Logger.php +++ b/kiri-engine/Abstracts/Logger.php @@ -32,6 +32,16 @@ class Logger implements LoggerInterface const LOGGER_LEVELS = [Logger::EMERGENCY, Logger::ALERT, Logger::CRITICAL, Logger::ERROR, Logger::WARNING, Logger::NOTICE, Logger::INFO, Logger::DEBUG]; + private array $levels = []; + + + + public function __construct() + { + $this->levels = Config::get('log.level', Logger::LOGGER_LEVELS); + } + + /** * @param string $message * @param array $context @@ -131,11 +141,9 @@ class Logger implements LoggerInterface * @param array $context * @throws */ - public function log($level, $message, array $context = []) + public function log($level, $message, array $context = []): void { - // TODO: Implement log() method. - $levels = Config::get('log.level', Logger::LOGGER_LEVELS); - if (!in_array($level, $levels)) { + if (!in_array($level, $this->levels)) { return; } $_string = "[" . now() . ']' . ucfirst($level) . ": " . $message . PHP_EOL;