From 102bc35016b1ecd2689f125a12286ce525dcc7b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 23 Jul 2021 10:38:03 +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/Error/Logger.php | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/System/Error/Logger.php b/System/Error/Logger.php index 6a89155e..ccedb259 100644 --- a/System/Error/Logger.php +++ b/System/Error/Logger.php @@ -48,7 +48,7 @@ class Logger extends Component */ public function debug(mixed $message, string $method = 'app', $file = null) { - if (Config::get('environment') == 'pro') { + if (Config::get('environment', 'pro') == 'pro') { return; } $this->output($message); @@ -62,7 +62,7 @@ class Logger extends Component */ public function trance(mixed $message, string $method = 'app') { - if (Config::get('environment') == 'pro') { + if (Config::get('environment', 'pro') == 'pro') { return; } $this->output($message); @@ -88,7 +88,7 @@ class Logger extends Component */ public function success(mixed $message, string $method = 'app', $file = null) { - if (Config::get('environment') == 'pro') { + if (Config::get('environment', 'pro') == 'pro') { return; } $this->output($message); @@ -300,26 +300,12 @@ class Logger extends Component */ public function exception(Throwable $exception): mixed { - $errorInfo = [ - 'message' => $exception->getMessage(), - 'file' => $exception->getFile(), - 'line' => $exception->getLine() - ]; - $this->error(var_export($errorInfo, true)); - $code = $exception->getCode() == 0 ? 500 : $exception->getCode(); $logger = Snowflake::app()->getLogger(); - -// $string = 'Exception: ' . PHP_EOL; -// $string .= '#. message: ' . $errorInfo['message'] . PHP_EOL; -// $string .= '#. file: ' . $errorInfo['file'] . PHP_EOL; -// $string .= '#. line: ' . $errorInfo['line'] . PHP_EOL; -// -// $logger->write($string . $exception->getTraceAsString(), 'trace'); $logger->write(jTraceEx($exception), 'exception'); - return Json::to($code, $errorInfo['message'], [ + return Json::to($code, $exception->getMessage(), [ 'file' => $exception->getFile(), 'line' => $exception->getLine() ]);