fix: 确保日志目录存在以避免写入日志失败
在多个文件中添加了检查并创建日志目录的逻辑,防止因目录不存在而导致日志写入失败
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user