mongodb-log-writer
Advanced tools
Comparing version
@@ -49,3 +49,6 @@ "use strict"; | ||
const leastRecentFileHeap = new heap_js_1.Heap((a, b) => a.fileTimestamp - b.fileTimestamp); | ||
let usedStorageSize = this._options.retentionGB ? 0 : -Infinity; | ||
const hasRetentionGB = !!this._options.retentionGB && isFinite(this._options.retentionGB); | ||
const hasMaxLogFileCount = !!this._options.maxLogFileCount && | ||
isFinite(this._options.maxLogFileCount); | ||
let usedStorageSize = hasRetentionGB ? 0 : -Infinity; | ||
try { | ||
@@ -68,3 +71,3 @@ for await (const dirent of dirHandle) { | ||
let fileSize; | ||
if (this._options.retentionGB) { | ||
if (hasRetentionGB) { | ||
try { | ||
@@ -79,6 +82,7 @@ fileSize = (await fs_1.promises.stat(fullPath)).size; | ||
} | ||
if (this._options.maxLogFileCount || this._options.retentionGB) { | ||
if (hasMaxLogFileCount || hasRetentionGB) { | ||
leastRecentFileHeap.push({ fullPath, fileTimestamp, fileSize }); | ||
} | ||
if (this._options.maxLogFileCount && | ||
if (hasMaxLogFileCount && | ||
this._options.maxLogFileCount && | ||
leastRecentFileHeap.size() > this._options.maxLogFileCount) { | ||
@@ -98,3 +102,3 @@ const toDelete = leastRecentFileHeap.pop(); | ||
} | ||
if (this._options.retentionGB) { | ||
if (hasRetentionGB && this._options.retentionGB) { | ||
const storageSizeLimit = this._options.retentionGB * 1024 * 1024 * 1024; | ||
@@ -101,0 +105,0 @@ for (const file of leastRecentFileHeap) { |
{ | ||
"name": "mongodb-log-writer", | ||
"description": "A library for writing MongoDB logv2 messages", | ||
"version": "2.3.4", | ||
"version": "2.4.0", | ||
"author": { | ||
@@ -91,3 +91,3 @@ "name": "MongoDB Inc", | ||
}, | ||
"gitHead": "2d439475e37b1f19086369b938916397add5b260" | ||
"gitHead": "3e5cd91accce46dbff9000133e0912111e16852c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
43103
0.95%415
0.97%