From 44db93be7e945a0f9a9b1a1cb87ec28fbd7f731d Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Fri, 31 May 2024 11:50:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E5=A4=84=E7=90=86tp?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90=E7=9A=84=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=96=87=E4=BB=B6=20=E8=AE=BF=E9=97=AE=E6=97=A0=E6=9D=83?= =?UTF-8?q?=E9=99=90=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/src/think/log/driver/File.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/vendor/topthink/framework/src/think/log/driver/File.php b/vendor/topthink/framework/src/think/log/driver/File.php index e5682fc..e51df92 100644 --- a/vendor/topthink/framework/src/think/log/driver/File.php +++ b/vendor/topthink/framework/src/think/log/driver/File.php @@ -67,7 +67,7 @@ class File implements LogHandlerInterface $destination = $this->getMasterLogFile(); $path = dirname($destination); - !is_dir($path) && mkdir($path, 0755, true); + !is_dir($path) && mkdir($path, 0755, true) && chmod($path,0777); $info = []; @@ -123,7 +123,22 @@ class File implements LogHandlerInterface $message = implode(PHP_EOL, $info) . PHP_EOL; - return error_log($message, 3, $destination); + // return error_log($message, 3, $destination); + /** 解决root生成的文件,www用户没有写权限的问题 */ + if (!is_file($destination)) { + $first = true; + } + + $ret = error_log($message, 3, $destination); + + try { + if (isset($first) && is_file($destination)) { + chmod($destination, 0777); + unset($first); + } + } catch (\Exception $e) { } + return $ret; + /** 解决root生成的文件,www用户没有写权限的问题 */ } /**