diff --git a/core/Abstracts/Logger.php b/core/Abstracts/Logger.php index d1c0486e..e97148b1 100644 --- a/core/Abstracts/Logger.php +++ b/core/Abstracts/Logger.php @@ -154,7 +154,7 @@ class Logger implements LoggerInterface * @param array $context * @throws ConfigException */ - private function log($level, $message, array $context = array()) + public function log($level, $message, array $context = array()) { // TODO: Implement log() method. $levels = Config::get('log.level', Logger::LOGGER_LEVELS); diff --git a/core/Error/Logger.php b/core/Error/Logger.php index 01b6f849..b26c9a6d 100644 --- a/core/Error/Logger.php +++ b/core/Error/Logger.php @@ -12,13 +12,10 @@ namespace Kiri\Error; use Annotation\Inject; use Exception; use Kiri\Abstracts\Component; -use Kiri\Abstracts\Config; use Kiri\Core\Json; use Kiri\Events\EventProvider; -use Kiri\Exception\ConfigException; use Kiri\Kiri; use Psr\Log\LoggerInterface; -use Swoole\Coroutine; use Throwable; /** @@ -77,24 +74,6 @@ class Logger extends Component } - - - /** - * @throws Exception - * 写入日志 - */ - public function insert() - { - if (empty($this->logs)) { - return; - } - foreach ($this->logs as $method => $message) { - $this->write($message, $method); - } - $this->logs = []; - } - - /** * @param Throwable $exception * @return mixed @@ -114,5 +93,19 @@ class Logger extends Component } + /** + * @param string $name + * @param array $arguments + * @return mixed + */ + public function __call(string $name, array $arguments): mixed + { + if (!method_exists($this, $name)) { + return $this->logger->{$name}(...$arguments); + } else { + return $this->{$name}(...$arguments); + } + } + } diff --git a/http-helper/Abstracts/HttpService.php b/http-helper/Abstracts/HttpService.php index 2c1dee86..ccf45f38 100644 --- a/http-helper/Abstracts/HttpService.php +++ b/http-helper/Abstracts/HttpService.php @@ -26,7 +26,6 @@ abstract class HttpService extends Component { $logger = Kiri::app()->getLogger(); $logger->write($message, $category); - $logger->insert(); } /**