| 70 | const MAX_LOG_ROTATIONS = 3; |
| 71 | |
| 72 | function rotateLogIfNeeded(logPath: string): void { |
| 73 | if (!existsSync(logPath)) { |
| 74 | return; |
| 75 | } |
| 76 | |
| 77 | const size = statSync(logPath).size; |
| 78 | if (size < MAX_LOG_BYTES) { |
| 79 | return; |
| 80 | } |
| 81 | |
| 82 | for (let index = MAX_LOG_ROTATIONS - 1; index >= 1; index -= 1) { |
| 83 | const from = `${logPath}.${index}`; |
| 84 | const to = `${logPath}.${index + 1}`; |
| 85 | if (existsSync(from)) { |
| 86 | renameSync(from, to); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | renameSync(logPath, `${logPath}.1`); |
| 91 | } |
| 92 | |
| 93 | function resolveDaemonLogPath(workspaceKey: string): string | null { |
| 94 | const override = process.env.XCODEBUILDMCP_DAEMON_LOG_PATH?.trim(); |