()
| 66 | } |
| 67 | |
| 68 | function rotateLogIfNeeded(): string | null { |
| 69 | const waveDataDir = getWaveDataDir(); |
| 70 | const logFile = path.join(waveDataDir, "waveapp.log"); |
| 71 | const logsDir = path.join(waveDataDir, "logs"); |
| 72 | |
| 73 | if (!fs.existsSync(logsDir)) { |
| 74 | fs.mkdirSync(logsDir, { recursive: true }); |
| 75 | } |
| 76 | |
| 77 | if (!fs.existsSync(logFile)) { |
| 78 | return null; |
| 79 | } |
| 80 | |
| 81 | const stats = fs.statSync(logFile); |
| 82 | if (stats.size > 10 * 1024 * 1024) { |
| 83 | const nextNum = findHighestLogNumber(logsDir) + 1; |
| 84 | const rotatedPath = path.join(logsDir, `waveapp.${nextNum}.log`); |
| 85 | fs.renameSync(logFile, rotatedPath); |
| 86 | return rotatedPath; |
| 87 | } |
| 88 | return null; |
| 89 | } |
| 90 | |
| 91 | let logRotateError: any = null; |
| 92 | let rotatedPath: string | null = null; |
no test coverage detected