debug.log 保留策略:只留最近3天+≤5MB,任一超标即清理到两条件同时满足

This commit is contained in:
ypsdf1
2026-10-05 13:35:39 +08:00
parent e040e8c994
commit ce489d1450
5 changed files with 190 additions and 2 deletions
+5
View File
@@ -45,6 +45,11 @@ function debugLog($msg, $ctx = []) {
if ($ctx) $entry .= ' | Context: ' . json_encode($ctx, JSON_UNESCAPED_UNICODE);
$entry .= "\n";
@file_put_contents($logFile, $entry, FILE_APPEND | LOCK_EX);
// ★ 保留策略(2026-10-05):只留最近3天 + ≤5MB,任一超标即清理到两条件同时满足
if (is_file(__DIR__ . '/../log_maintain.php')) {
@require_once __DIR__ . '/../log_maintain.php';
if (function_exists('logMaintain')) { @logMaintain($logFile); }
}
}
} // end if (!function_exists('debugLog'))