From f9c6ecafdb6ac4fef02635c3bf26effa25e36705 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 1 Mar 2016 22:41:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BError=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Error.php | 7 ++----- library/think/log/driver/Trace.php | 11 +++++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/library/think/Error.php b/library/think/Error.php index de0f2dec..d146c2bf 100644 --- a/library/think/Error.php +++ b/library/think/Error.php @@ -141,13 +141,10 @@ class Error */ public static function output($exception, array $vars) { - if ($exception instanceof Exception) { - http_response_code($exception->getHttpStatus()); - } else { - http_response_code(500); - } + http_response_code($exception instanceof \Exception ? $exception->getHttpStatus() : 500); $type = Config::get('default_return_type'); + if (IS_API && 'html' != $type) { // 异常信息输出监听 APP_HOOK && Hook::listen('error_output', $data); diff --git a/library/think/log/driver/Trace.php b/library/think/log/driver/Trace.php index 3b30b8e7..690db49b 100644 --- a/library/think/log/driver/Trace.php +++ b/library/think/log/driver/Trace.php @@ -54,9 +54,12 @@ class Trace '查询信息' => \think\Db::$queryTimes . ' queries ' . \think\Db::$executeTimes . ' writes ', '缓存信息' => \think\Cache::$readTimes . ' reads,' . \think\Cache::$writeTimes . ' writes', '配置加载' => count(Config::get()), - '会话信息' => 'SESSION_ID=' . session_id(), ]; + if (session_id()) { + $base['会话信息'] = 'SESSION_ID=' . session_id(); + } + $info = Debug::getFile(true); // 获取调试日志 @@ -70,13 +73,13 @@ class Trace foreach ($this->tabs as $name => $title) { $name = strtolower($name); switch ($name) { - case 'base': // 基本信息 + case 'base': // 基本信息 $trace[$title] = $base; break; - case 'file': // 文件信息 + case 'file': // 文件信息 $trace[$title] = $info; break; - default: // 调试信息 + default: // 调试信息 if (strpos($name, '|')) { // 多组信息 $names = explode('|', $name);