mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
fixed 优化ApiLog文件夹不存在的报错
This commit is contained in:
parent
1468ed7a96
commit
7c3a9d8742
@ -84,7 +84,7 @@ class ApiLog {
|
|||||||
self::$userInfo
|
self::$userInfo
|
||||||
));
|
));
|
||||||
if (!file_exists($logPath)) {
|
if (!file_exists($logPath)) {
|
||||||
mkdir($logPath);
|
mkdir($logPath, 0755, true);
|
||||||
}
|
}
|
||||||
@file_put_contents($logPath . date('YmdH') . '.log', $logStr . "\n", FILE_APPEND);
|
@file_put_contents($logPath . date('YmdH') . '.log', $logStr . "\n", FILE_APPEND);
|
||||||
}
|
}
|
||||||
@ -95,7 +95,10 @@ class ApiLog {
|
|||||||
* @param string $type 日志文件名称
|
* @param string $type 日志文件名称
|
||||||
* @param string $filePath
|
* @param string $filePath
|
||||||
*/
|
*/
|
||||||
public static function writeLog($log, $type = 'sql', $filePath = '.' . DS . 'runtime' . DS) {
|
public static function writeLog($log, $type = 'sql', $filePath = '') {
|
||||||
|
if(!$filePath) {
|
||||||
|
$filePath = '.' . DS . 'runtime' . DS;
|
||||||
|
}
|
||||||
$filename = $filePath . date("Ymd") . '_' . $type . ".log";
|
$filename = $filePath . date("Ymd") . '_' . $type . ".log";
|
||||||
@$handle = fopen($filename, "a+");
|
@$handle = fopen($filename, "a+");
|
||||||
@fwrite($handle, date('Y-m-d H:i:s') . "\t" . $log . "\r\n");
|
@fwrite($handle, date('Y-m-d H:i:s') . "\t" . $log . "\r\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user