|
|
@@ -10,6 +10,7 @@ use UCore\Command\Command;
|
|
|
*
|
|
|
* 持续运行的日志收集命令,循环100次后退出,间隔1秒
|
|
|
* 复用CollectUserLogsCommand的核心逻辑
|
|
|
+ * php artisan game:collect-user-logs-continuous
|
|
|
*/
|
|
|
class CollectUserLogsContinuousCommand extends Command
|
|
|
{
|
|
|
@@ -77,7 +78,7 @@ class CollectUserLogsContinuousCommand extends Command
|
|
|
$this->line("循环 {$i} ");
|
|
|
|
|
|
$cycleStartTime = microtime(true);
|
|
|
-
|
|
|
+
|
|
|
try {
|
|
|
if ($detail) {
|
|
|
$this->line("🔄 第 {$i}/{$cycles} 次循环开始...");
|
|
|
@@ -85,10 +86,10 @@ class CollectUserLogsContinuousCommand extends Command
|
|
|
|
|
|
// 复用原有的收集逻辑
|
|
|
$result = $this->executeTimelineCollection($manager, $limit, $detail);
|
|
|
-
|
|
|
+
|
|
|
$cycleEndTime = microtime(true);
|
|
|
$cycleExecutionTime = round(($cycleEndTime - $cycleStartTime) * 1000, 2);
|
|
|
-
|
|
|
+
|
|
|
$totalProcessed += $result['processed_count'];
|
|
|
$totalExecutionTime += $cycleExecutionTime;
|
|
|
$successfulCycles++;
|
|
|
@@ -105,7 +106,7 @@ class CollectUserLogsContinuousCommand extends Command
|
|
|
} catch (\Exception $e) {
|
|
|
$failedCycles++;
|
|
|
$this->error("❌ 第 {$i} 次循环失败: {$e->getMessage()}");
|
|
|
-
|
|
|
+
|
|
|
if ($detail) {
|
|
|
$this->line("🚨 错误详情: " . $e->getTraceAsString());
|
|
|
}
|
|
|
@@ -189,32 +190,32 @@ class CollectUserLogsContinuousCommand extends Command
|
|
|
$this->line("");
|
|
|
$this->info("🎉 持续收集完成!");
|
|
|
$this->line("");
|
|
|
-
|
|
|
+
|
|
|
$this->line("📊 <comment>执行统计</comment>:");
|
|
|
$this->line(" 🔄 总循环次数: <info>{$totalCycles}</info>");
|
|
|
$this->line(" ✅ 成功次数: <info>{$successfulCycles}</info>");
|
|
|
-
|
|
|
+
|
|
|
if ($failedCycles > 0) {
|
|
|
$this->line(" ❌ 失败次数: <error>{$failedCycles}</error>");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$this->line(" 📝 总处理记录: <info>{$totalProcessed}</info>");
|
|
|
$this->line(" ⏱️ 总执行时间: <info>{$totalExecutionTime}ms</info>");
|
|
|
$this->line(" 🕐 总运行时间: <info>{$totalRealTime}ms</info>");
|
|
|
-
|
|
|
+
|
|
|
if ($totalProcessed > 0) {
|
|
|
$avgTimePerRecord = round($totalExecutionTime / $totalProcessed, 2);
|
|
|
$this->line(" 📈 平均处理时间: <info>{$avgTimePerRecord}ms/条</info>");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if ($successfulCycles > 0) {
|
|
|
$avgRecordsPerCycle = round($totalProcessed / $successfulCycles, 2);
|
|
|
$this->line(" 📊 平均每次处理: <info>{$avgRecordsPerCycle}条</info>");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$successRate = round(($successfulCycles / $totalCycles) * 100, 2);
|
|
|
$this->line(" 🎯 成功率: <info>{$successRate}%</info>");
|
|
|
-
|
|
|
+
|
|
|
$this->line("");
|
|
|
}
|
|
|
}
|