From e3c90ea9ad2bb6a9fe1c9c4110d48eff195fa19b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BA=A6=E5=BD=93=E8=8B=97=E5=84=BF?= Date: Tue, 1 Mar 2016 15:59:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E7=BD=B2=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E5=BC=82=E5=B8=B8=E9=A1=B5=E9=9D=A2=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=BF=A1=E6=81=AF=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Error.php | 6 +- tpl/think_exception.tpl | 162 ++++++++++++++++++++-------------------- 2 files changed, 86 insertions(+), 82 deletions(-) diff --git a/library/think/Error.php b/library/think/Error.php index d53b73f0..de0f2dec 100644 --- a/library/think/Error.php +++ b/library/think/Error.php @@ -65,18 +65,18 @@ class Error 'ThinkPHP Constants' => self::getTPConst(), ], ]; - $err_msg = "[{$data['code']}]{$data['message']}[{$data['file']}:{$data['line']}]"; + $log = "[{$data['code']}]{$data['message']}[{$data['file']}:{$data['line']}]"; } else { // 部署模式仅显示 Code 和 Message $data = [ 'code' => $exception->getCode(), 'message' => Config::get('show_error_msg') ? $exception->getMessage() : Config::get('error_message'), ]; - $err_msg = "[{$data['code']}]{$data['message']}"; + $log = "[{$data['code']}]{$data['message']}"; } // 记录异常日志 - Log::record($err_msg, 'error'); + Log::record($log, 'error'); // 输出错误信息 self::output($exception, $data); // 禁止往下传播已处理过的异常 diff --git a/tpl/think_exception.tpl b/tpl/think_exception.tpl index 3309cf3d..bbcbd726 100644 --- a/tpl/think_exception.tpl +++ b/tpl/think_exception.tpl @@ -1,78 +1,4 @@ - -'.end($names).''; - } -} -if (!function_exists('parse_file')) { - function parse_file($file, $line) - { - return ''.basename($file)." line {$line}".''; - } -} -if (!function_exists('parse_args')) { - function parse_args($args) - { - $result = []; - - foreach ($args as $key => $item) { - switch (true) { - case is_object($item): - $value = sprintf('object(%s)', parse_class(get_class($item))); - break; - case is_array($item): - if(count($item) > 3){ - $value = sprintf('[%s, ...]', parse_args(array_slice($item, 0, 3))); - } else { - $value = sprintf('[%s]', parse_args($item)); - } - break; - case is_string($item): - if(strlen($item) > 20){ - $value = sprintf( - '\'%s...\'', - htmlentities($item), - htmlentities(substr($item, 0, 20)) - ); - } else { - $value = sprintf("'%s'", htmlentities($item)); - } - break; - case is_int($item): - case is_float($item): - $value = $item; - break; - case is_null($item): - $value = 'null'; - break; - case is_bool($item): - $value = '' . ($item ? 'true' : 'false') . ''; - break; - case is_resource($item): - $value = 'resource'; - break; - default: - $value = htmlentities(str_replace("\n", '', var_export(strval($item), true))); - break; - } - - $result[] = is_int($key) ? $value : "'{$key}' => {$value}"; - } - - return implode(', ', $result); - } -} -?> + @@ -150,7 +76,7 @@ if (!function_exists('parse_args')) { display: inline-block; min-width: 100%; box-sizing: border-box; - padding-left: px; + padding-left: px; } .exception .source-code pre li{ border-left: 1px solid #ddd; @@ -240,6 +166,7 @@ if (!function_exists('parse_args')) { +

@@ -281,6 +208,13 @@ if (!function_exists('parse_args')) {

+ +
+

+
+

+
+
@@ -315,6 +249,7 @@ if (!function_exists('parse_args')) {
+

Environment Variables

$value) { ?> @@ -345,13 +280,14 @@ if (!function_exists('parse_args')) {
+ - + + - \ No newline at end of file + +'.end($names).''; + } + + function parse_file($file, $line) + { + return ''.basename($file)." line {$line}".''; + } + + function parse_args($args) + { + $result = []; + + foreach ($args as $key => $item) { + switch (true) { + case is_object($item): + $value = sprintf('object(%s)', parse_class(get_class($item))); + break; + case is_array($item): + if(count($item) > 3){ + $value = sprintf('[%s, ...]', parse_args(array_slice($item, 0, 3))); + } else { + $value = sprintf('[%s]', parse_args($item)); + } + break; + case is_string($item): + if(strlen($item) > 20){ + $value = sprintf( + '\'%s...\'', + htmlentities($item), + htmlentities(substr($item, 0, 20)) + ); + } else { + $value = sprintf("'%s'", htmlentities($item)); + } + break; + case is_int($item): + case is_float($item): + $value = $item; + break; + case is_null($item): + $value = 'null'; + break; + case is_bool($item): + $value = '' . ($item ? 'true' : 'false') . ''; + break; + case is_resource($item): + $value = 'resource'; + break; + default: + $value = htmlentities(str_replace("\n", '', var_export(strval($item), true))); + break; + } + + $result[] = is_int($key) ? $value : "'{$key}' => {$value}"; + } + + return implode(', ', $result); + }