@spinajs/log
Advanced tools
Comparing version 1.2.65 to 1.2.68
import { Bootstrapper } from "@spinajs/di"; | ||
export declare class LogBotstrapper extends Bootstrapper { | ||
bootstrap(): Promise<void>; | ||
bootstrap(): void; | ||
} |
@@ -10,2 +10,3 @@ "use strict"; | ||
exports.LogBotstrapper = void 0; | ||
const FileTarget_1 = require("./targets/FileTarget"); | ||
const di_1 = require("@spinajs/di"); | ||
@@ -15,4 +16,18 @@ const log_1 = require("./log"); | ||
let LogBotstrapper = class LogBotstrapper extends di_1.Bootstrapper { | ||
async bootstrap() { | ||
bootstrap() { | ||
di_1.DI.register(log_configuration_1.default).asValue("__configurationSchema__"); | ||
// register factory for file target, | ||
// becouse we want to create target | ||
// only one per target not one for every logger | ||
di_1.DI.register((container, options) => { | ||
const fileTargets = container.get(Array.ofType("__log_file_targets__")); | ||
let target = fileTargets.find((t) => t.Options.name === options.name); | ||
if (!target) { | ||
target = container.resolve("__file_target_implementation__", [options]); | ||
container.register(target).asValue("__log_file_targets__"); | ||
return target; | ||
} | ||
return target; | ||
}).as("FileTarget"); | ||
di_1.DI.register(FileTarget_1.FileTarget).as("__file_target_implementation__"); | ||
process.on("uncaughtException", (err) => { | ||
@@ -19,0 +34,0 @@ const log = di_1.DI.resolve(log_1.Log, ["process"]); |
@@ -58,3 +58,2 @@ "use strict"; | ||
if (this.CurrentFileSize > this.Options.options.maxSize) { | ||
internal_logger_1.InternalLogger.debug(`File ${this.LogPath} exceeded log size ( current: ${this.CurrentFileSize}, max: ${this.Options.options.maxSize})`, "file-target"); | ||
this.archive(); | ||
@@ -120,3 +119,2 @@ } | ||
rotate() { | ||
internal_logger_1.InternalLogger.debug(`Initializing rotating log files at schedule ${this.Options.options.rotate}`, "file-target"); | ||
if (this.Options.options.rotate) { | ||
@@ -163,3 +161,2 @@ this.RotateJob = (0, node_schedule_1.scheduleJob)(`LogScheduleJob`, this.Options.options.rotate, () => { | ||
} | ||
internal_logger_1.InternalLogger.debug(`Creating log file at path ${this.LogPath}`, "file-target"); | ||
this.HasError = false; | ||
@@ -170,3 +167,2 @@ this.Error = null; | ||
FileTarget = __decorate([ | ||
(0, di_1.Injectable)("FileTarget"), | ||
(0, di_1.NewInstance)() | ||
@@ -173,0 +169,0 @@ ], FileTarget); |
@@ -11,5 +11,5 @@ import { SyncModule } from "@spinajs/di"; | ||
Error: Error | null | unknown; | ||
protected Options: T; | ||
Options: T; | ||
constructor(options: T); | ||
abstract write(data: ILogEntry): Promise<void>; | ||
} |
{ | ||
"name": "@spinajs/log", | ||
"version": "1.2.65", | ||
"version": "1.2.68", | ||
"description": "Log lib for all spinejs related libs", | ||
@@ -29,4 +29,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@spinajs/configuration": "^1.2.62", | ||
"@spinajs/di": "^1.2.32", | ||
"@spinajs/configuration": "^1.2.68", | ||
"@spinajs/di": "^1.2.68", | ||
"@spinajs/exceptions": "^1.2.7", | ||
@@ -45,3 +45,3 @@ "@spinajs/log-common": "^1.2.60", | ||
}, | ||
"gitHead": "995346bcfb06146fcc3e8871360c66e34f449f12" | ||
"gitHead": "4df6ba1f117af546434773102c1a564b34ca9f12" | ||
} |
Sorry, the diff of this file is not supported yet
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
192318
1433
Updated@spinajs/di@^1.2.68