(filename, highWaterMarkBytes, retryReopenDelayMS, checkFileRotationIntervalMS)
| 9 | |
| 10 | class ServerAccessLogger { |
| 11 | constructor(filename, highWaterMarkBytes, retryReopenDelayMS, checkFileRotationIntervalMS) { |
| 12 | this._filename = filename; |
| 13 | this._highWaterMarkBytes = highWaterMarkBytes; |
| 14 | this._retryReopenDelayMS = retryReopenDelayMS; |
| 15 | this._stat = undefined; |
| 16 | this._waitingDrain = false; |
| 17 | this._terminated = false; |
| 18 | this._reopenStream(); |
| 19 | |
| 20 | setInterval(() => { this._checkFileRotated(); }, checkFileRotationIntervalMS); |
| 21 | |
| 22 | process.on('beforeExit', () => { |
| 23 | this._cleanOldStream(true); |
| 24 | this._terminated = true; |
| 25 | }); |
| 26 | process.on('SIGINT', () => { |
| 27 | this._cleanOldStream(true); |
| 28 | this._terminated = true; |
| 29 | }); |
| 30 | process.on('SIGTERM', () => { |
| 31 | this._cleanOldStream(true); |
| 32 | this._terminated = true; |
| 33 | }); |
| 34 | process.on('uncaughtException', () => { |
| 35 | this._cleanOldStream(true); |
| 36 | this._terminated = true; |
| 37 | }); |
| 38 | } |
| 39 | |
| 40 | _checkFileRotated() { |
| 41 | logger.debug('ServerAccessLogger: check file rotation'); |
nothing calls this directly
no test coverage detected