From 912a4b3ad8e581b828a8d5fb5747023146c86cc1 Mon Sep 17 00:00:00 2001 From: Fabian Stamm Date: Fri, 28 Sep 2018 12:37:13 +0200 Subject: [PATCH] Adding simplified custom logger initialisation --- out/index.d.ts | 2 +- out/index.js | 49 ++++++++++++++++++++------------------------- out/index.js.map | 2 +- out/test.js | 15 +++++++------- out/test.js.map | 2 +- package.json | 2 +- src/index.ts | 52 ++++++++++++++++++++++-------------------------- src/test.ts | 19 +++++++++++------- 8 files changed, 70 insertions(+), 73 deletions(-) diff --git a/out/index.d.ts b/out/index.d.ts index 6e473ff..a96c8d5 100644 --- a/out/index.d.ts +++ b/out/index.d.ts @@ -52,7 +52,7 @@ export declare class LoggingBase { private fileSize; private errorSize; private queue; - constructor(options?: Partial); + constructor(options?: Partial | string); console_out: boolean; waitForSetup(): Promise; private setup; diff --git a/out/index.js b/out/index.js index dcfe4ae..c04894e 100644 --- a/out/index.js +++ b/out/index.js @@ -40,14 +40,21 @@ class LoggingBase { this.errorSize = 0; this.queue = new Array(); this.events = new events_1.EventEmitter(); + let opt; if (!options) - options = {}; - if (options.name) { - if (options.logfile === undefined) { - options.logfile = `./logs/all.${options.name}.log`; + opt = {}; + else if (typeof options === "string") { + opt = { name: options }; + } + else { + opt = options; + } + if (opt.name) { + if (opt.logfile === undefined) { + opt.logfile = `./logs/all.${opt.name}.log`; } - if (options.errorfile === undefined) { - options.errorfile = `./logs/error.${options.name}.log`; + if (opt.errorfile === undefined) { + opt.errorfile = `./logs/error.${opt.name}.log`; } } this.config = Object.assign({ @@ -55,7 +62,7 @@ class LoggingBase { console_out: true, logfile: "./logs/all.log", errorfile: "./logs/error.log" - }, options); + }, opt); for (let key in this) { if (typeof this[key] === "function") this[key] = this[key].bind(this); @@ -170,7 +177,7 @@ class LoggingBase { this.events.emit("message", { type: type, message: mb }); } writeMessageToFile(message, error) { - if (!this.writeLock.locked && !this.fileStream && !(error || this.errorStream)) + if (this.setted_up && (!this.fileStream || (error && !this.errorStream))) return; this.queue.push({ message: message.replace("\n", " "), error: error }); this.checkQueue(); @@ -218,24 +225,12 @@ class LoggingBase { } async initializeFile(file, new_file = true) { try { - await new Promise((resolve, reject) => { - const folder = path.dirname(file); - if (folder) - fs.exists(folder, (exists) => { - if (!exists) { - fs.mkdir(folder, (err) => { - if (err) { - reject(err); - } - else { - resolve(); - } - }); - } - else - resolve(); - }); - }); + const folder = path.dirname(file); + if (folder) { + if (!await fsExists(folder)) { + await fsMkDir(folder).catch(() => { }); //Could happen, if two seperate logger want to create folder so ignoring + } + } let size = 0; if (await fsExists(file)) { let stats = await fsStat(file); @@ -321,7 +316,7 @@ function fsExists(path) { } function fsMkDir(path) { return new Promise((resolve, reject) => { - fs.exists(path, resolve); + fs.mkdir(path, (err) => err ? reject(err) : resolve()); }); } function getStack() { diff --git a/out/index.js.map b/out/index.js.map index 663f99d..f3978f8 100644 --- a/out/index.js.map +++ b/out/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAC7B,yBAAyB;AACzB,mCAAsC;AACtC,6BAA6B;AAC7B,iCAA0B;AAEb,QAAA,MAAM,GAAG;IACnB,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,SAAS;IACjB,GAAG,EAAE,SAAS;IACd,UAAU,EAAE,SAAS;IACrB,KAAK,EAAE,SAAS;IAChB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,SAAS;IAEjB,OAAO,EAAE,UAAU;IACnB,KAAK,EAAE,UAAU;IACjB,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,UAAU;IAClB,SAAS,EAAE,UAAU;IACrB,MAAM,EAAE,UAAU;IAClB,OAAO,EAAE,UAAU;IAEnB,OAAO,EAAE,UAAU;IACnB,KAAK,EAAE,UAAU;IACjB,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,UAAU;IAClB,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C,IAAI,CAAC;iBAC7B,CAAC;aACJ;SACH;KACH;AACJ,CAAC;AAED,IAAY,YAKX;AALD,WAAY,YAAY;IACrB,6CAAG,CAAA;IACH,qDAAO,CAAA;IACP,iDAAK,CAAA;IACL,iDAAK,CAAA;AACR,CAAC,EALW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAKvB"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAC7B,yBAAyB;AACzB,mCAAsC;AACtC,6BAA6B;AAC7B,iCAA0B;AAEb,QAAA,MAAM,GAAG;IACnB,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,SAAS;IACjB,GAAG,EAAE,SAAS;IACd,UAAU,EAAE,SAAS;IACrB,KAAK,EAAE,SAAS;IAChB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,SAAS;IAEjB,OAAO,EAAE,UAAU;IACnB,KAAK,EAAE,UAAU;IACjB,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,UAAU;IAClB,SAAS,EAAE,UAAU;IACrB,MAAM,EAAE,UAAU;IAClB,OAAO,EAAE,UAAU;IAEnB,OAAO,EAAE,UAAU;IACnB,KAAK,EAAE,UAAU;IACjB,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,UAAU;IAClB,SAAS,EAAE,UAAU;IACrB,MAAM,EAAE,UAAU;IAClB,OAAO,EAAE,UAAU;CACrB,CAAA;AAED,MAAM,WAAW,GAAG,SAAS,CAAC;AAE9B,MAAM,0BAA0B,GAAS,KAAK,CAAC,SAAU,CAAC,iBAAiB,CAAA;AAqB3E,MAAa,WAAW;IAarB,YAAY,OAA8C;QAXlD,cAAS,GAAG,IAAI,cAAI,EAAE,CAAC;QAEvB,cAAS,GAAG,KAAK,CAAC;QAIlB,aAAQ,GAAW,CAAC,CAAC;QACrB,cAAS,GAAW,CAAC,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C,WAAW,CAAC,WAAW,EAAE,CAAC;oBAC9C,IAAI,EAAE,WAAW,CAAC,aAAa,EAAE;iBACnC,CAAC;SACP;KACH;IAAC,OAAO,GAAG,EAAE,GAAG;IACjB,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AACvC,CAAC;AAED,SAAS,qBAAqB,CAAC,GAAU;IACtC,IAAI,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IACxC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAA,sBAAsB;IACpC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QACtB,IAAI,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;QACzB,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAA;QAC/D,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YAChC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YACrC,IAAI,CAAC,IAAI,OAAO,EAAE;gBACf,OAAO;oBACJ,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC;iBAC7B,CAAC;aACJ;SACH;KACH;AACJ,CAAC;AAED,IAAY,YAKX;AALD,WAAY,YAAY;IACrB,6CAAG,CAAA;IACH,qDAAO,CAAA;IACP,iDAAK,CAAA;IACL,iDAAK,CAAA;AACR,CAAC,EALW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAKvB"} \ No newline at end of file diff --git a/out/test.js b/out/test.js index 24b4c6d..e9d9a36 100644 --- a/out/test.js +++ b/out/test.js @@ -1,7 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const index_1 = require("./index"); -const crypto_1 = require("crypto"); index_1.Logging.log("test"); index_1.Logging.log("i", "am", { a: "an" }, 1000); index_1.Logging.error(new Error("fehler 001")); @@ -11,12 +10,14 @@ index_1.Logging.log("\x1b[31m\x1b[31m\x1b[31m\x1b[31m\x1b[31m\x1b[31m TEST \x1b[ let err = new Error(); if (typeof err.stack !== "string") console.log("Stacktrace invalid", err.stack); -index_1.Logging.console_out = false; -index_1.Logging.waitForSetup().then(() => { - for (let i = 0; i < 7000; i++) { - index_1.Logging.log(crypto_1.randomBytes(50000).toString("hex")); - } -}); let cus = new index_1.LoggingBase({ name: "test" }); cus.log("Hello from custom Logger"); +let cus2 = new index_1.LoggingBase("test2"); +cus2.log("Hello from custom Logger 2"); +// Logging.console_out = false; +// Logging.waitForSetup().then(() => { +// for (let i = 0; i < 7000; i++) { +// Logging.log(randomBytes(50000).toString("hex")) +// } +// }); //# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/out/test.js.map b/out/test.js.map index c6d727d..02b42b9 100644 --- a/out/test.js.map +++ b/out/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";;AAAA,mCAA+C;AAC/C,mCAAqC;AAErC,eAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AACnB,eAAO,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;AAC1C,eAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;AACvC,eAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;AAClC,eAAO,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAE/C,eAAO,CAAC,GAAG,CAAC,gFAAgF,CAAC,CAAA;AAE7F,IAAI,GAAG,GAAG,IAAI,KAAK,EAAE,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GAAG,CAAC,KAAK,CAAC,CAAA;AAE/E,IAAI,GAAG,GAAG,IAAI,mBAAW,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AAC5C,GAAG,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA;AAEnC,IAAI,IAAI,GAAG,IAAI,mBAAW,CAAC,OAAO,CAAC,CAAC;AACpC,IAAI,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAEtC,+BAA+B;AAC/B,sCAAsC;AACtC,sCAAsC;AACtC,wDAAwD;AACxD,OAAO;AACP,MAAM"} \ No newline at end of file diff --git a/package.json b/package.json index 79cd62a..1eeff39 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hibas123/nodelogging", - "version": "1.3.14", + "version": "1.3.15", "description": "", "main": "out/index.js", "types": "out/index.d.ts", diff --git a/src/index.ts b/src/index.ts index 0b25333..f9f5c67 100644 --- a/src/index.ts +++ b/src/index.ts @@ -68,15 +68,21 @@ export class LoggingBase { private queue = new Array<{ message: string, error: boolean }>(); - constructor(options?: Partial) { - if (!options) options = {}; - if (options.name) { - if (options.logfile === undefined) { - options.logfile = `./logs/all.${options.name}.log` + constructor(options?: Partial | string) { + let opt: Partial; + if (!options) opt = {} + else if (typeof options === "string") { + opt = { name: options }; + } else { + opt = options; + } + if (opt.name) { + if (opt.logfile === undefined) { + opt.logfile = `./logs/all.${opt.name}.log` } - if (options.errorfile === undefined) { - options.errorfile = `./logs/error.${options.name}.log` + if (opt.errorfile === undefined) { + opt.errorfile = `./logs/error.${opt.name}.log` } } this.config = Object.assign({ @@ -84,19 +90,18 @@ export class LoggingBase { console_out: true, logfile: "./logs/all.log", errorfile: "./logs/error.log" - }, options); + }, opt); for (let key in this) { if (typeof this[key] === "function") this[key] = (this[key]).bind(this); } - } get console_out() { return this.config.console_out; } - set console_out(value) { + set console_out(value: boolean) { this.config.console_out = value; } @@ -122,7 +127,7 @@ export class LoggingBase { this.checkQueue(); } - events: EventEmitter = new EventEmitter(); + public events: EventEmitter = new EventEmitter(); debug(...message: any[]) { this.message(LoggingTypes.Debug, message); @@ -211,7 +216,7 @@ export class LoggingBase { } private writeMessageToFile(message: string, error?: boolean) { - if (!this.writeLock.locked && !this.fileStream && !(error || this.errorStream)) return; + if (this.setted_up && (!this.fileStream || (error && !this.errorStream))) return; this.queue.push({ message: message.replace("\n", " "), error: error }); this.checkQueue(); } @@ -256,21 +261,12 @@ export class LoggingBase { private async initializeFile(file: string, new_file = true): Promise<{ stream: fs.WriteStream, size: number }> { try { - await new Promise((resolve, reject) => { - const folder = path.dirname(file); - if (folder) - fs.exists(folder, (exists) => { - if (!exists) { - fs.mkdir(folder, (err) => { - if (err) { - reject(err); - } else { - resolve(); - } - }); - } else resolve(); - }); - }); + const folder = path.dirname(file); + if (folder) { + if (!await fsExists(folder)) { + await fsMkDir(folder).catch(() => { }); //Could happen, if two seperate logger want to create folder so ignoring + } + } let size = 0; if (await fsExists(file)) { @@ -360,7 +356,7 @@ function fsExists(path) { function fsMkDir(path) { return new Promise((resolve, reject) => { - fs.exists(path, resolve); + fs.mkdir(path, (err) => err ? reject(err) : resolve()); }); } diff --git a/src/test.ts b/src/test.ts index 4a93c8b..7bb17b6 100644 --- a/src/test.ts +++ b/src/test.ts @@ -11,11 +11,16 @@ Logging.log("\x1b[31m\x1b[31m\x1b[31m\x1b[31m\x1b[31m\x1b[31m TEST \x1b[31m\x1b[ let err = new Error() if (typeof err.stack !== "string") console.log("Stacktrace invalid", err.stack) -Logging.console_out = false; -Logging.waitForSetup().then(() => { - for (let i = 0; i < 7000; i++) { - Logging.log(randomBytes(50000).toString("hex")) - } -}); + let cus = new LoggingBase({ name: "test" }); -cus.log("Hello from custom Logger") \ No newline at end of file +cus.log("Hello from custom Logger") + +let cus2 = new LoggingBase("test2"); +cus2.log("Hello from custom Logger 2") + +// Logging.console_out = false; +// Logging.waitForSetup().then(() => { +// for (let i = 0; i < 7000; i++) { +// Logging.log(randomBytes(50000).toString("hex")) +// } +// }); \ No newline at end of file