diff --git a/api/poller_online.php b/api/poller_online.php index 837fd9f..a137462 100644 --- a/api/poller_online.php +++ b/api/poller_online.php @@ -114,20 +114,15 @@ function getPlatformDB() { $user = defined('PAY_MYSQL_USER') ? PAY_MYSQL_USER : 'hbye3AezRNk4r7YA'; $pass = defined('PAY_MYSQL_PASS') ? PAY_MYSQL_PASS : '5HtD7Rn3seRAn2BE'; - debugLog('[poller] 正在连接平台MySQL...', [ - 'host' => $host, - 'db' => $dbname, - 'user' => $user, - ]); + // ★ 2026-10-05 日志收敛:连接过程(正在连接/DSN/连接成功)属于每次轮询的 + // 常规路径,一律不写日志——补单器约 20 秒跑一次,这 3 行是 debug.log + // 膨胀的元凶之一。只有下面 catch 的"连接失败"(报错)才写日志。 $start = microtime(true); $dsn = "mysql:host=$host;dbname=$dbname;charset=utf8mb4"; - debugLog('[poller] MySQL DSN: ' . $dsn); $pdo = new PDO($dsn, $user, $pass, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_TIMEOUT => 15, ]); - $elapsed = round((microtime(true) - $start) * 1000); - debugLog("[poller] MySQL连接成功", ['elapsed_ms' => $elapsed]); return $pdo; } catch (\Throwable $e) { $elapsed = round((microtime(true) - ($start ?? microtime(true))) * 1000); @@ -172,7 +167,8 @@ function pollerAcquireLock() { function pollPaidOrders() { global $PLATFORM_DB_PREFIX; $startTime = microtime(true); - debugLog('[poller] 补单开始'); + // ★ 2026-10-05 日志收敛:不再无条件写"补单开始"。没有合适订单时下面直接 + // 静默 return(只回 JSON,不写日志);只有真正补到单(成功)或出错才写。 // 并发保护:已有补单进程在跑则直接跳过,杜绝重复补单 if (!pollerAcquireLock()) { @@ -320,7 +316,11 @@ function pollPaidOrders() { } $elapsed = round((microtime(true) - $startTime) * 1000); - debugLog('[poller] 补单完成', ['processed' => $processed, 'skipped' => $skipped, 'elapsed_ms' => $elapsed]); + // ★ 2026-10-05 日志收敛:只在本轮真正补到单(processed > 0)时写"补单完成"; + // 没有实际补单动作则静默,不再每轮刷一条。 + if ($processed > 0) { + debugLog('[poller] 补单完成', ['processed' => $processed, 'skipped' => $skipped, 'elapsed_ms' => $elapsed]); + } echo json_encode([ 'result' => 'ok', diff --git a/api/sync.php b/api/sync.php index 0267ed3..8d6547c 100644 --- a/api/sync.php +++ b/api/sync.php @@ -2390,7 +2390,12 @@ function checkWebLoginConfirmations() { unset($conf); } - debugLog("checkWebLoginConfirmations: 轮询", ['count' => count($confirmations), 'players' => $playerNames]); + // ★ 2026-10-05 日志收敛:count=0(没有待处理的确认数据)时静默返回,不写日志。 + // 该接口被 Java 每 4 秒轮询一次,count=0 占绝大多数,是 debug.log 膨胀主因之一。 + // 只有真有待处理的确认记录(= 有数据可消费)或出错才写日志。 + if (!empty($confirmations)) { + debugLog("checkWebLoginConfirmations: 轮询", ['count' => count($confirmations), 'players' => $playerNames]); + } // 标记为已消费(一次性) if (!empty($playerNames)) { @@ -2399,6 +2404,7 @@ function checkWebLoginConfirmations() { $db->exec("DELETE FROM web_login_confirmations WHERE consumed = 1 AND confirmed_at < " . (time() - 1800)); } } catch (\Throwable $e) { + debugLog("checkWebLoginConfirmations: 错误", ['error' => $e->getMessage()]); @error_log("[checkWebLoginConfirmations] error: " . $e->getMessage()); } @@ -2415,7 +2421,7 @@ function checkWebLoginVerified() { } $playerName = getParam('player_name'); - debugLog("check_web_login_verified: 插件查询Web验证记录", ['player_name' => $playerName]); + // ★ 2026-10-05 日志收敛:"插件查询Web验证记录"只是进查询、还没有数据,不再写日志。 $db = getDB(); $db->exec("CREATE TABLE IF NOT EXISTS web_login_verified (player_name TEXT PRIMARY KEY, verified_at INTEGER NOT NULL)"); @@ -2443,9 +2449,8 @@ function checkWebLoginVerified() { $delStmt->bindValue(':player', $playerName, SQLITE3_TEXT); $delStmt->execute(); debugLog("check_web_login_verified: 找到验证记录并消费", ['player_name' => $playerName, 'verified_at' => $row['verified_at']]); - } else { - debugLog("check_web_login_verified: 未找到验证记录", ['player_name' => $playerName]); } + // ★ 2026-10-05 日志收敛:未找到验证记录 = 没有合适数据,静默(不写日志)。 } else { // 批量获取所有验证记录(用于轮询) $stmt = $db->prepare("SELECT player_name, verified_at FROM web_login_verified WHERE verified_at >= :expire"); @@ -2458,14 +2463,14 @@ function checkWebLoginVerified() { if (!empty($verified)) { $db->exec("DELETE FROM web_login_verified WHERE verified_at >= " . $expireTime); debugLog("check_web_login_verified: 批量消费验证记录", ['count' => count($verified), 'players' => array_column($verified, 'player_name')]); - } else { - debugLog("check_web_login_verified: 无验证记录", []); } + // ★ 2026-10-05 日志收敛:无验证记录 = 没有合适数据,静默(不写日志)。 } $db->exec("COMMIT"); } catch (\Throwable $e) { try { $db->exec("ROLLBACK"); } catch (\Throwable $e2) {} + debugLog("check_web_login_verified: 错误", ['error' => $e->getMessage()]); } success($verified); @@ -2685,6 +2690,8 @@ function checkPendingWebLogins() { try { $db->exec("DELETE FROM web_login_requests WHERE request_time < " . (time() - 600)); } catch (\Throwable $e) { + // ★ 2026-10-05 日志收敛:报错(清理失败)写日志 + debugLog("checkPendingWebLogins: 清理过期请求失败", ['error' => $e->getMessage()]); @error_log("[checkPendingWebLogins] cleanup error: " . $e->getMessage()); } @@ -2697,7 +2704,12 @@ function checkPendingWebLogins() { $requests[] = $row; } - debugLog("checkPendingWebLogins: 轮询", ['count' => count($requests), 'players' => array_column($requests, 'player_name')]); + // ★ 2026-10-05 日志收敛:count=0(没有待处理的密码登录请求)时静默,不写日志; + // 该接口被 Java 每 4 秒轮询一次,count=0 是常态,是 debug.log 膨胀主因之一。 + // 只有真有待处理请求(有数据)或出错才写日志。 + if (!empty($requests)) { + debugLog("checkPendingWebLogins: 轮询", ['count' => count($requests), 'players' => array_column($requests, 'player_name')]); + } success($requests); }