fix: 确保日志目录存在以避免写入日志失败

在多个文件中添加了检查并创建日志目录的逻辑,防止因目录不存在而导致日志写入失败
This commit is contained in:
2025-12-12 02:50:40 +08:00
parent 5438b944b8
commit 89a22c7b11
4 changed files with 55 additions and 0 deletions
+10
View File
@@ -64,12 +64,22 @@ try {
// 计算新的持续时间(分钟)
// #region agent log
$log_data = json_encode(['location' => 'update_booking.php:65', 'message' => 'Calculating duration', 'data' => ['start_time' => $new_start_time, 'end_time' => $new_end_time], 'timestamp' => time() * 1000, 'sessionId' => 'debug-session', 'runId' => 'run1', 'hypothesisId' => 'C']);
// 确保日志目录存在
$log_dir = '.cursor';
if (!file_exists($log_dir)) {
mkdir($log_dir, 0777, true);
}
file_put_contents('.cursor/debug.log', $log_data . "\n", FILE_APPEND);
// #endregion
$interval = $start_dt->diff($end_dt);
$duration = ($interval->days * 24 * 60) + ($interval->h * 60) + $interval->i;
// #region agent log
$log_data = json_encode(['location' => 'update_booking.php:67', 'message' => 'Duration calculated', 'data' => ['duration' => $duration, 'days' => $interval->days, 'hours' => $interval->h, 'minutes' => $interval->i], 'timestamp' => time() * 1000, 'sessionId' => 'debug-session', 'runId' => 'run1', 'hypothesisId' => 'C']);
// 确保日志目录存在
$log_dir = '.cursor';
if (!file_exists($log_dir)) {
mkdir($log_dir, 0777, true);
}
file_put_contents('.cursor/debug.log', $log_data . "\n", FILE_APPEND);
// #endregion