This commit is contained in:
ASUS 2025-08-18 11:16:13 +08:00
parent 59b98c073b
commit 08811a8953
1 changed files with 0 additions and 29 deletions

View File

@ -10,35 +10,6 @@ class LogMiddleware implements MiddlewareInterface
{
public function process(Request $request, callable $handler): Response
{
// 使用示例
$logFile = '/rh/webman_duanju/runtime/logs/webman-' . date('Y-m-d') . '.log';
// 确保目录存在
$logDir = dirname($logFile);
if (!is_dir($logDir)) {
mkdir($logDir, 0755, true); // 创建目录权限755
}
$filePath = $logFile;
// 检查文件是否存在
if (!file_exists($filePath)) {
// 如果文件不存在,先创建文件
if (!touch($filePath)) {
error_log("无法创建文件: $filePath");
}
}
// 检查当前是否已有写入权限
if (is_writable($filePath)) {
// 已有写入权限,无需修改
}else {
// 尝试设置权限
if (chmod($filePath, 0664)) {
} else {
error_log("无法给文件设置权限:" . $filePath . "权限值:" . 0664);
}
}
// 定义颜色
$green = "\033[32m"; // 标题/分隔
$yellow = "\033[33m"; // 方法/状态码