From 016a5bf6b9bf922d0d30a7b50e31eb463eb9ef6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=B1=95=E9=B9=8F?= Date: Fri, 5 Dec 2025 17:11:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A1=AE=E4=BF=9D=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E5=AD=98=E5=9C=A8=E4=BB=A5=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E5=86=99=E5=85=A5=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在写入日志前检查目录是否存在,不存在时自动创建,防止因目录缺失导致的日志写入失败 --- webhook.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/webhook.php b/webhook.php index d810072..3252e7f 100644 --- a/webhook.php +++ b/webhook.php @@ -66,6 +66,13 @@ function log_message($message, $type = 'info') { global $log_file; $timestamp = date('Y-m-d H:i:s'); $log_entry = "[$timestamp] [$type] $message\n"; + + // 检查日志目录是否存在,如果不存在则创建 + $log_dir = dirname($log_file); + if (!is_dir($log_dir)) { + mkdir($log_dir, 0755, true); + } + file_put_contents($log_file, $log_entry, FILE_APPEND); }