From ed8741629ebddb7c5bbc904c89140b77f44cf20d Mon Sep 17 00:00:00 2001 From: "upfy@qq.com" Date: Tue, 8 Dec 2015 15:30:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20socketlog=20=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/org/slog.php | 6 +++--- library/think/app.php | 1 + library/think/error.php | 4 +++- mode/common.php | 3 +-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/library/org/slog.php b/library/org/slog.php index 07cc5f25..3a22f71d 100644 --- a/library/org/slog.php +++ b/library/org/slog.php @@ -120,7 +120,7 @@ class Slog } set_error_handler([__CLASS__, 'error_handler']); - register_shutdown_function([__CLASS__, 'fatalError'])); + register_shutdown_function([__CLASS__, 'fatalError']); } public static function error_handler($errno, $errstr, $errfile, $errline) @@ -260,7 +260,7 @@ class Slog } //记录日志 - public function record($type, $msg = '', $css = '') + public static function record($type, $msg = '', $css = '') { if (!self::check()) { return; @@ -373,7 +373,7 @@ class Slog { if (in_array($method, self::$log_types)) { array_unshift($args, $method); - return call_user_func_array(self::record, $args); + return call_user_func_array(['\org\Slog','record'], $args); } } diff --git a/library/think/app.php b/library/think/app.php index 25fe51fa..e03889af 100644 --- a/library/think/app.php +++ b/library/think/app.php @@ -58,6 +58,7 @@ class App } //判断,如果启动SocketLog调试, 进行SocketLog配置 if ($config['slog']['enable']) { + define('SLOG_ENABLE',true); \org\Slog::config($config['slog']); } diff --git a/library/think/error.php b/library/think/error.php index d47e01e3..24e778f8 100644 --- a/library/think/error.php +++ b/library/think/error.php @@ -70,7 +70,9 @@ class Error { // 记录日志 Log::save(); - \org\Slog::sendLog(); + if(defined('SLOG_ENABLE') && SLOG_ENABLE) { + \org\Slog::sendLog(); + } if ($e = error_get_last()) { switch ($e['type']) { case E_ERROR: diff --git a/mode/common.php b/mode/common.php index 64e32015..1156e533 100644 --- a/mode/common.php +++ b/mode/common.php @@ -42,8 +42,7 @@ return [ 'think\Url' => CORE_PATH . 'url' . EXT, 'think\Debug' => CORE_PATH . 'debug' . EXT, 'think\Input' => CORE_PATH . 'input' . EXT, - 'think\Lang' => CORE_PATH . 'lang' . EXT, - 'think\Slog' => CORE_PATH . 'slog' . EXT + 'think\Lang' => CORE_PATH . 'lang' . EXT ], 'init' => [],