From 11bc94720592b6854dc58f8273603e7521d9c5ff Mon Sep 17 00:00:00 2001 From: Fabian Stamm Date: Thu, 10 May 2018 20:11:53 +0200 Subject: [PATCH] making shure to not destroy Error stack permanently --- out/index.js | 39 +++++++++++++++++++++++++++------------ out/index.js.map | 2 +- out/test.d.ts | 1 + out/test.js | 3 +++ out/test.js.map | 2 +- package.json | 2 +- src/index.ts | 48 +++++++++++++++++++++++++++++++++++------------- src/test.ts | 3 +++ 8 files changed, 72 insertions(+), 28 deletions(-) diff --git a/out/index.js b/out/index.js index b476b12..b974e70 100644 --- a/out/index.js +++ b/out/index.js @@ -28,6 +28,7 @@ const BgMagenta = "\x1b[45m"; const BgCyan = "\x1b[46m"; const BgWhite = "\x1b[47m"; const maxFileSize = 500000000; +const OriginalErrorStackFunction = Error.prototype.prepareStackTrace; class Logging { static config(logfolder, stdout) { this.logFileLocation = logfolder; @@ -50,11 +51,11 @@ class Logging { Logging.errorMessage(error); return; } - let m = ""; - error.stack.forEach(e => { - m += e.toString() + "\n"; - }); - var message = error.name + " " + error.message + "\n" + m; + // let m = ""; + // (error.stack).forEach(e => { + // m += e.toString() + "\n"; + // }) + var message = error.name + " " + error.message + "\n" + error.stack; Logging.message(LoggingTypes.Error, [message]); } static errorMessage(...message) { @@ -284,15 +285,29 @@ function fsMkDir(path) { fs.exists(path, resolve); }); } +function getStack() { + // Save original Error.prepareStackTrace + let origPrepareStackTrace = Error.prepareStackTrace; + // Override with function that just returns `stack` + Error.prepareStackTrace = function (_, stack) { + return stack; + }; + // Create a new `Error`, which automatically gets `stack` + let err = new Error(); + // Evaluate `err.stack`, which calls our new `Error.prepareStackTrace` + let stack = err.stack; + // Restore original `Error.prepareStackTrace` + Error.prepareStackTrace = origPrepareStackTrace; + // Remove superfluous function call on stack + stack.shift(); // getStack --> Error + return stack; +} function _getCallerFile() { try { - var err = new Error(); - var caller_file; - var current_file; - Error.prepareStackTrace = function (err, stack) { return stack; }; - current_file = err.stack.shift().getFileName(); - while (err.stack.length) { - caller_file = err.stack.shift().getFileName(); + let stack = getStack(); + let current_file = stack.shift().getFileName(); + while (stack.length) { + let caller_file = stack.shift().getFileName(); if (current_file !== caller_file) return path.basename(caller_file); } diff --git a/out/index.js.map b/out/index.js.map index c1d73d4..f922148 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;AAE7B,MAAM,KAAK,GAAG,SAAS,CAAA;AACvB,MAAM,MAAM,GAAG,SAAS,CAAA;AACxB,MAAM,GAAG,GAAG,SAAS,CAAA;AACrB,MAAM,UAAU,GAAG,SAAS,CAAA;AAC5B,MAAM,KAAK,GAAG,SAAS,CAAA;AACvB,MAAM,OAAO,GAAG,SAAS,CAAA;AACzB,MAAM,MAAM,GAAG,SAAS,CAAA;AAExB,MAAM,OAAO,GAAG,UAAU,CAAA;AAC1B,MAAM,KAAK,GAAG,UAAU,CAAA;AACxB,MAAM,OAAO,GAAG,UAAU,CAAA;AAC1B,MAAM,QAAQ,GAAG,UAAU,CAAA;AAC3B,MAAM,MAAM,GAAG,UAAU,CAAA;AACzB,MAAM,SAAS,GAAG,UAAU,CAAA;AAC5B,MAAM,MAAM,GAAG,UAAU,CAAA;AACzB,MAAM,OAAO,GAAG,UAAU,CAAA;AAE1B,MAAM,OAAO,GAAG,UAAU,CAAA;AAC1B,MAAM,KAAK,GAAG,UAAU,CAAA;AACxB,MAAM,OAAO,GAAG,UAAU,CAAA;AAC1B,MAAM,QAAQ,GAAG,UAAU,CAAA;AAC3B,MAAM,MAAM,GAAG,UAAU,CAAA;AACzB,MAAM,SAAS,GAAG,UAAU,CAAA;AAC5B,MAAM,MAAM,GAAG,UAAU,CAAA;AACzB,MAAM,OAAO,GAAG,UAAU,CAAA;AAE1B,MAAM,WAAW,GAAG,SAAS,CAAC;AAE9B;IAcG,MAAM,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R,CAAC,EALW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAKvB"} \ No newline at end of file diff --git a/out/test.d.ts b/out/test.d.ts index e69de29..cb0ff5c 100644 --- a/out/test.d.ts +++ b/out/test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/out/test.js b/out/test.js index 2836bd3..7ad54cf 100644 --- a/out/test.js +++ b/out/test.js @@ -8,6 +8,9 @@ index_1.Logging.error(new Error("fehler 001")); index_1.Logging.debug("Some Debug infos"); index_1.Logging.errorMessage("i", "am", "an", "error"); index_1.Logging.log("\x1b[31m\x1b[31m\x1b[31m\x1b[31m\x1b[31m\x1b[31m TEST \x1b[31m\x1b[31m\x1b[31m"); +let err = new Error(); +if (typeof err.stack !== "string") + console.log("Stacktrace invalid", err.stack); index_1.Logging.stdout = false; for (let i = 0; i < 7000; i++) { index_1.Logging.log(crypto_1.randomBytes(50000).toString("hex")); diff --git a/out/test.js.map b/out/test.js.map index 3078a79..869c7c4 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,mCAAkC;AAClC,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,eAAO,CAAC,MAAM,GAAG,KAAK,CAAC;AACvB,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;IAC7B,eAAO,CAAC,GAAG,CAAC,oBAAW,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;AAClD,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";;AAAA,mCAAkC;AAClC,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,CAAA;AACrB,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ;IAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,GAAG,CAAC,KAAK,CAAC,CAAA;AAE/E,eAAO,CAAC,MAAM,GAAG,KAAK,CAAC;AACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE;IAC5B,eAAO,CAAC,GAAG,CAAC,oBAAW,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;CACjD"} \ No newline at end of file diff --git a/package.json b/package.json index 8ce5b63..6db3f05 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "logger-perfcloud", - "version": "1.1.3", + "version": "1.2.0", "description": "", "main": "out/index.js", "types": "out/index.d.ts", diff --git a/src/index.ts b/src/index.ts index 0ee399e..16049ba 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,6 +31,8 @@ const BgWhite = "\x1b[47m" const maxFileSize = 500000000; +const OriginalErrorStackFunction = (Error.prototype).prepareStackTrace + export class Logging { private static logFileLocation: string = "./logs/"; public static stdout: boolean = true; @@ -71,11 +73,11 @@ export class Logging { Logging.errorMessage(error); return; } - let m = ""; - (error.stack).forEach(e => { - m += e.toString() + "\n"; - }) - var message = error.name + " " + error.message + "\n" + m; + // let m = ""; + // (error.stack).forEach(e => { + // m += e.toString() + "\n"; + // }) + var message = error.name + " " + error.message + "\n" + error.stack; Logging.message(LoggingTypes.Error, [message]); } @@ -298,18 +300,38 @@ function fsMkDir(path) { }); } +function getStack() { + // Save original Error.prepareStackTrace + let origPrepareStackTrace = (Error).prepareStackTrace; + + // Override with function that just returns `stack` + (Error).prepareStackTrace = function (_, stack) { + return stack + } + + // Create a new `Error`, which automatically gets `stack` + let err = new Error(); + + // Evaluate `err.stack`, which calls our new `Error.prepareStackTrace` + let stack: any[] = err.stack; + + // Restore original `Error.prepareStackTrace` + (Error).prepareStackTrace = origPrepareStackTrace; + + // Remove superfluous function call on stack + stack.shift(); // getStack --> Error + + return stack +} + function _getCallerFile() { try { - var err = new Error(); - var caller_file: string; - var current_file: string; + let stack = getStack() - (Error).prepareStackTrace = function (err, stack) { return stack; }; + let current_file = stack.shift().getFileName(); - current_file = (err.stack).shift().getFileName(); - - while (err.stack.length) { - caller_file = (err.stack).shift().getFileName(); + while (stack.length) { + let caller_file = stack.shift().getFileName(); if (current_file !== caller_file) return path.basename(caller_file); } } catch (err) { } diff --git a/src/test.ts b/src/test.ts index 06074af..6ba3367 100644 --- a/src/test.ts +++ b/src/test.ts @@ -9,6 +9,9 @@ Logging.errorMessage("i", "am", "an", "error"); Logging.log("\x1b[31m\x1b[31m\x1b[31m\x1b[31m\x1b[31m\x1b[31m TEST \x1b[31m\x1b[31m\x1b[31m") +let err = new Error() +if (typeof err.stack !== "string") console.log("Stacktrace invalid", err.stack) + Logging.stdout = false; for (let i = 0; i < 7000; i++) { Logging.log(randomBytes(50000).toString("hex"))