作者 邓超

1

... ... @@ -49,7 +49,9 @@ function db():\Lib\DbPool{
* @time 2023/2/10 14:58
*/
function logs($message,$filename=null){
if(is_array($message)){
$message = print_r($message,true);
}
\Lib\Log::append($message, $filename);
}
... ...
... ... @@ -304,7 +304,7 @@ class App {
// 记录日志
if($last_error = error_get_last()){
logs(print_r($last_error,true));
logs($last_error);
$data['error_message'] = $last_error['message'];
$data['status'] = 502;
... ...
... ... @@ -33,7 +33,7 @@ class Log {
*/
public function __construct()
{
$this->filename['default'] = LOG_PATH.'/'.app()->nowDate().'.error.log';
$this->setFilename();
}
/**
... ... @@ -48,7 +48,7 @@ class Log {
self::getInstance()->setFilename($filename);
}
self::getInstance()->message[md5($filename)][] = $message;
self::getInstance()->message[$filename ? md5($filename) : 'default'][] = $message;
}
... ... @@ -71,16 +71,18 @@ class Log {
* @author:dc
* @time 2023/3/14 11:11
*/
private function setFilename($filename){
private function setFilename($filename=null){
if($filename){
$this->filename[md5($filename)] = $filename;
}else{
$this->filename['default'] = $filename = LOG_PATH.'/'.app()->nowDate().'.error.log';
}
// 创建目录
if(!is_dir(dirname($filename))){
@mkdir(dirname($filename),0755,true);
}
$this->filename[md5($filename)] = $filename;
}
/**
... ...