作者 邓超

1

@@ -49,7 +49,9 @@ function db():\Lib\DbPool{ @@ -49,7 +49,9 @@ function db():\Lib\DbPool{
49 * @time 2023/2/10 14:58 49 * @time 2023/2/10 14:58
50 */ 50 */
51 function logs($message,$filename=null){ 51 function logs($message,$filename=null){
52 - 52 + if(is_array($message)){
  53 + $message = print_r($message,true);
  54 + }
53 \Lib\Log::append($message, $filename); 55 \Lib\Log::append($message, $filename);
54 56
55 } 57 }
@@ -304,7 +304,7 @@ class App { @@ -304,7 +304,7 @@ class App {
304 304
305 // 记录日志 305 // 记录日志
306 if($last_error = error_get_last()){ 306 if($last_error = error_get_last()){
307 - logs(print_r($last_error,true)); 307 + logs($last_error);
308 308
309 $data['error_message'] = $last_error['message']; 309 $data['error_message'] = $last_error['message'];
310 $data['status'] = 502; 310 $data['status'] = 502;
@@ -33,7 +33,7 @@ class Log { @@ -33,7 +33,7 @@ class Log {
33 */ 33 */
34 public function __construct() 34 public function __construct()
35 { 35 {
36 - $this->filename['default'] = LOG_PATH.'/'.app()->nowDate().'.error.log'; 36 + $this->setFilename();
37 } 37 }
38 38
39 /** 39 /**
@@ -48,7 +48,7 @@ class Log { @@ -48,7 +48,7 @@ class Log {
48 self::getInstance()->setFilename($filename); 48 self::getInstance()->setFilename($filename);
49 } 49 }
50 50
51 - self::getInstance()->message[md5($filename)][] = $message; 51 + self::getInstance()->message[$filename ? md5($filename) : 'default'][] = $message;
52 52
53 } 53 }
54 54
@@ -71,16 +71,18 @@ class Log { @@ -71,16 +71,18 @@ class Log {
71 * @author:dc 71 * @author:dc
72 * @time 2023/3/14 11:11 72 * @time 2023/3/14 11:11
73 */ 73 */
74 - private function setFilename($filename){ 74 + private function setFilename($filename=null){
  75 + if($filename){
  76 + $this->filename[md5($filename)] = $filename;
  77 + }else{
  78 + $this->filename['default'] = $filename = LOG_PATH.'/'.app()->nowDate().'.error.log';
  79 + }
75 80
76 // 创建目录 81 // 创建目录
77 if(!is_dir(dirname($filename))){ 82 if(!is_dir(dirname($filename))){
78 @mkdir(dirname($filename),0755,true); 83 @mkdir(dirname($filename),0755,true);
79 } 84 }
80 85
81 - $this->filename[md5($filename)] = $filename;  
82 -  
83 -  
84 } 86 }
85 87
86 /** 88 /**