()
| 71 | |
| 72 | // ponytail: rename-based rotation, atomic, no rewrite, ~20MB total ceiling |
| 73 | private rotateIfNeeded(): void { |
| 74 | let size = 0 |
| 75 | try { |
| 76 | size = fs.statSync(this.logFile).size |
| 77 | } catch { |
| 78 | return // file doesn't exist yet |
| 79 | } |
| 80 | if (size < MAX_SIZE_BYTES) return |
| 81 | fs.renameSync(this.logFile, this.oldLogFile) // overwrites previous .old, atomic |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | function resolveThreshold(): LogLevel { |