改进Log类的record方法

This commit is contained in:
thinkphp
2016-06-14 14:24:25 +08:00
parent c9155c016d
commit 15aeb6d7f4
5 changed files with 12 additions and 6 deletions

View File

@@ -80,9 +80,6 @@ class Log
*/ */
public static function record($msg, $type = 'log') public static function record($msg, $type = 'log')
{ {
if (!is_string($msg)) {
$msg = var_export($msg, true);
}
self::$log[$type][] = $msg; self::$log[$type][] = $msg;
} }
@@ -153,9 +150,6 @@ class Log
*/ */
public static function write($msg, $type = 'log') public static function write($msg, $type = 'log')
{ {
if (!is_string($msg)) {
$msg = var_export($msg, true);
}
// 封装日志信息 // 封装日志信息
$log[$type][] = $msg; $log[$type][] = $msg;

View File

@@ -65,6 +65,9 @@ class File
$info = '[ log ] ' . $current_uri . $time_str . $memory_str . $file_load . "\r\n"; $info = '[ log ] ' . $current_uri . $time_str . $memory_str . $file_load . "\r\n";
foreach ($log as $type => $val) { foreach ($log as $type => $val) {
foreach ($val as $msg) { foreach ($val as $msg) {
if (!is_string($msg)) {
$msg = var_export($msg, true);
}
$info .= '[ ' . $type . ' ] ' . $msg . "\r\n"; $info .= '[ ' . $type . ' ] ' . $msg . "\r\n";
} }
} }

View File

@@ -44,6 +44,9 @@ class Sae
$info = '[ log ] ' . $current_uri . $time_str . $memory_str . $file_load . "\r\n"; $info = '[ log ] ' . $current_uri . $time_str . $memory_str . $file_load . "\r\n";
foreach ($log as $type => $val) { foreach ($log as $type => $val) {
foreach ($val as $msg) { foreach ($val as $msg) {
if (!is_string($msg)) {
$msg = var_export($msg, true);
}
$info .= '[ ' . $type . ' ] ' . $msg . "\r\n"; $info .= '[ ' . $type . ' ] ' . $msg . "\r\n";
} }
} }

View File

@@ -92,6 +92,9 @@ class Socket
'css' => isset($this->css[$type]) ? $this->css[$type] : '', 'css' => isset($this->css[$type]) ? $this->css[$type] : '',
]; ];
foreach ($val as $msg) { foreach ($val as $msg) {
if (!is_string($msg)) {
$msg = var_export($msg, true);
}
$trace[] = [ $trace[] = [
'type' => 'log', 'type' => 'log',
'msg' => $msg, 'msg' => $msg,

View File

@@ -72,6 +72,9 @@ class Trace
$debug = []; $debug = [];
foreach ($log as $type => $val) { foreach ($log as $type => $val) {
foreach ($val as $msg) { foreach ($val as $msg) {
if (!is_string($msg)) {
$msg = var_export($msg, true);
}
$debug[$type][] = $msg; $debug[$type][] = $msg;
} }
} }