@spinajs/log
Advanced tools
Comparing version 1.2.71 to 1.2.74
@@ -13,3 +13,2 @@ import { LogTarget } from "./LogTarget"; | ||
protected ArchiveJob: Job; | ||
protected LogFileDescriptor: number; | ||
protected CurrentFileSize: number; | ||
@@ -16,0 +15,0 @@ protected BufferSize: number; |
@@ -10,3 +10,2 @@ "use strict"; | ||
exports.FileTarget = void 0; | ||
const internal_logger_1 = require("@spinajs/internal-logger"); | ||
/* eslint security/detect-non-literal-fs-filename:0 -- Safe as no value holds user input */ | ||
@@ -41,5 +40,2 @@ const di_1 = require("@spinajs/di"); | ||
this.flush(); | ||
if (this.LogFileDescriptor) { | ||
fs.closeSync(this.LogFileDescriptor); | ||
} | ||
}); | ||
@@ -80,3 +76,2 @@ super.resolve(); | ||
} | ||
fs.closeSync(this.LogFileDescriptor); | ||
fs.copyFileSync(this.LogPath, archPath); | ||
@@ -99,9 +94,4 @@ fs.unlinkSync(this.LogPath); | ||
}); | ||
internal_logger_1.InternalLogger.debug(`Created archived compressed file at ${zippedPath}`, "file-target"); | ||
} | ||
else { | ||
internal_logger_1.InternalLogger.debug(`Created archived file at ${archPath}`, "file-target"); | ||
} | ||
if (files.length >= this.Options.options.maxArchiveFiles) { | ||
internal_logger_1.InternalLogger.debug(`Deleting old archive file ${files[0].name}`, "file-target"); | ||
fs.unlink(files[0].name, () => { | ||
@@ -113,6 +103,8 @@ return; | ||
flush() { | ||
if (!this.LogFileDescriptor || this.HasError || this.BufferSize === 0) { | ||
if (this.HasError || this.BufferSize === 0) { | ||
return; | ||
} | ||
fs.writeFileSync(this.LogFileDescriptor, this.Buffer.join()); | ||
const fd = fs.openSync(this.LogPath, "a"); | ||
fs.writeFileSync(fd, this.Buffer.join()); | ||
fs.closeSync(fd); | ||
this.CurrentFileSize += this.BufferSize; | ||
@@ -131,6 +123,2 @@ this.Buffer = []; | ||
this.flush(); | ||
if (this.LogFileDescriptor >= 0) { | ||
fs.closeSync(this.LogFileDescriptor); | ||
this.LogFileDescriptor = 0; | ||
} | ||
this.CurrentFileSize = 0; | ||
@@ -159,3 +147,2 @@ this.LogDirPath = path.dirname(path.resolve((0, configuration_1.format)(null, this.Options.options.path))); | ||
} | ||
this.LogFileDescriptor = fs.openSync(this.LogPath, "a"); | ||
if (this.Options.options.flushTimeout !== 0) { | ||
@@ -162,0 +149,0 @@ setTimeout(() => { |
{ | ||
"name": "@spinajs/log", | ||
"version": "1.2.71", | ||
"version": "1.2.74", | ||
"description": "Log lib for all spinejs related libs", | ||
@@ -44,3 +44,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "71472ae1c6f9f1aaca8ee96911b71498f693c994" | ||
"gitHead": "c1d99b8dbd4a7cf0d8e1457f1438a771e4d0725f" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
190747
1417