增加app_trace 参数用于配置是否开启trace调试

This commit is contained in:
thinkphp
2016-07-03 10:39:23 +08:00
parent fdfebe73f6
commit fbf9e938e8
5 changed files with 54 additions and 54 deletions

View File

@@ -9,6 +9,8 @@ return [
'app_namespace' => 'app', 'app_namespace' => 'app',
// 应用调试模式 // 应用调试模式
'app_debug' => true, 'app_debug' => true,
// 应用Trace
'app_trace' => false,
// 应用模式状态 // 应用模式状态
'app_status' => '', 'app_status' => '',
// 是否支持多模块 // 是否支持多模块
@@ -134,24 +136,26 @@ return [
'error_message' => '页面错误!请稍后再试~', 'error_message' => '页面错误!请稍后再试~',
// 显示错误信息 // 显示错误信息
'show_error_msg' => false, 'show_error_msg' => false,
// 异常处理handle类 留空使用 \think\exception\Handle
'exception_handle' => '',
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | 日志设置 // | 日志设置
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
'log' => [ 'log' => [
// 日志记录方式,支持 file sae // 日志记录方式,内置 file sae 支持扩展
'type' => 'File', 'type' => 'File',
// 日志保存目录 // 日志保存目录
'path' => LOG_PATH, 'path' => LOG_PATH,
], ],
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Trace设置 // | Trace设置 开启 app_trace 后 有效
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
'trace' => [ 'trace' => [
// 支持Html Socket Console 设为false则不显示 // 内置Html Socket Console 支持扩展
'type' => false, 'type' => 'Html',
], ],
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
@@ -245,6 +249,7 @@ return [
// 自动写入时间戳字段 // 自动写入时间戳字段
'auto_timestamp' => false, 'auto_timestamp' => false,
], ],
//分页配置 //分页配置
'paginate' => [ 'paginate' => [
'type' => 'bootstrap', 'type' => 'bootstrap',

View File

@@ -155,7 +155,9 @@ class App
Hook::listen('app_end', $response); Hook::listen('app_end', $response);
// Trace调试注入 // Trace调试注入
if (Config::get('app_trace')) {
Debug::inject($response); Debug::inject($response);
}
return $response; return $response;
} }

View File

@@ -188,8 +188,6 @@ class Debug
{ {
$config = Config::get('trace'); $config = Config::get('trace');
$type = isset($config['type']) ? $config['type'] : 'Html'; $type = isset($config['type']) ? $config['type'] : 'Html';
if (false !== $type) {
$request = Request::instance(); $request = Request::instance();
$accept = $request->header('accept'); $accept = $request->header('accept');
$contentType = $response->getHeader('Content-Type'); $contentType = $response->getHeader('Content-Type');
@@ -223,4 +221,3 @@ class Debug
} }
} }
} }
}

View File

@@ -98,24 +98,20 @@ class Error
/** /**
* Get an instance of the exception handler. * Get an instance of the exception handler.
* *
* @return \think\exception\Handle * @return Handle
*/ */
public static function getExceptionHandler() public static function getExceptionHandler()
{ {
static $handle; static $handle;
if (!$handle) { if (!$handle) {
// 异常处理handle
if ($class = Config::get('exception_handle')) { $class = Config::get('exception_handle');
if (class_exists($class) && is_subclass_of($class, "\\think\\exception\\Handle")) { if ($class && class_exists($class) && is_subclass_of($class, "\\think\\exception\\Handle")) {
$handle = new $class; $handle = new $class;
} else {
$handle = new Handle;
} }
} }
if (!$handle) {
$handle = new Handle();
}
}
return $handle; return $handle;
} }
} }

View File

@@ -10,6 +10,7 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace think; namespace think;
use think\exception\ClassNotFoundException; use think\exception\ClassNotFoundException;
/** /**
@@ -110,7 +111,6 @@ class Log
*/ */
public static function check($config) public static function check($config)
{ {
if (self::$key && !empty($config['allow_key']) && !in_array(self::$key, $config['allow_key'])) { if (self::$key && !empty($config['allow_key']) && !in_array(self::$key, $config['allow_key'])) {
return false; return false;
} }