MCPcopy
hub / github.com/wavetermdev/waveterm / rotateLogIfNeeded

Function rotateLogIfNeeded

emain/emain-log.ts:68–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

66}
67
68function 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
91let logRotateError: any = null;
92let rotatedPath: string | null = null;

Callers 1

emain-log.tsFile · 0.85

Calls 2

getWaveDataDirFunction · 0.90
findHighestLogNumberFunction · 0.85

Tested by

no test coverage detected