From 5bf06074607a084f000637e21606de8f61f4dfad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 23 Jul 2021 10:42:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/Abstracts/BaseObject.php | 2 +- System/Error/Logger.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/System/Abstracts/BaseObject.php b/System/Abstracts/BaseObject.php index dd665892..f90770e7 100644 --- a/System/Abstracts/BaseObject.php +++ b/System/Abstracts/BaseObject.php @@ -226,7 +226,7 @@ class BaseObject implements Configure if (!empty($file)) { $message .= PHP_EOL . "\033[41;37m[" . date('Y-m-d H:i:s') . '][ERROR]: ' . $file . "\033[0m"; } - $this->logger()->output($message . PHP_EOL); + $this->logger()->output($message . PHP_EOL, 'error'); } } diff --git a/System/Error/Logger.php b/System/Error/Logger.php index ccedb259..f993944f 100644 --- a/System/Error/Logger.php +++ b/System/Error/Logger.php @@ -14,6 +14,7 @@ use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Config; use Snowflake\Core\Json; use Snowflake\Event; +use Snowflake\Exception\ConfigException; use Snowflake\Snowflake; use Swoole\Coroutine; use Throwable; @@ -133,9 +134,15 @@ class Logger extends Component /** * @param $message + * @param string $method + * @throws ConfigException */ - public function output($message) + public function output($message, string $method = 'default') { + if ($method !== 'error' && + Config::get('environment', 'pro') == 'pro') { + return; + } if (str_contains($message, 'Event::rshutdown(): Event::wait()')) { return; }