From b9b65eccd3b26735896f2363d8b64bffd1f9da14 Mon Sep 17 00:00:00 2001 From: Vladyslav Karpenko Date: Sun, 15 Jan 2023 18:19:20 +0200 Subject: [PATCH] Fix error's stack filtering in the custom logger Signed-off-by: Vladyslav Karpenko --- JavaScript/9-logger/logger.js | 2 +- JavaScript/a-config/logger.js | 2 +- JavaScript/b-transport/logger.js | 2 +- JavaScript/c-commonjs/logger.js | 2 +- JavaScript/d-messenger/lib/logger.js | 6 +++--- JavaScript/d-messenger/main.js | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/JavaScript/9-logger/logger.js b/JavaScript/9-logger/logger.js index d1006f2..a7ed2c4 100644 --- a/JavaScript/9-logger/logger.js +++ b/JavaScript/9-logger/logger.js @@ -16,7 +16,7 @@ const DATETIME_LENGTH = 19; class Logger { constructor(logPath) { - this.path = logPath; + this.path = process.cwd(); const date = new Date().toISOString().substring(0, 10); const filePath = path.join(logPath, `${date}.log`); this.stream = fs.createWriteStream(filePath, { flags: 'a' }); diff --git a/JavaScript/a-config/logger.js b/JavaScript/a-config/logger.js index 80b172e..1121d1d 100644 --- a/JavaScript/a-config/logger.js +++ b/JavaScript/a-config/logger.js @@ -16,7 +16,7 @@ const DATETIME_LENGTH = 19; class Logger { constructor(logPath) { - this.path = logPath; + this.path = process.cwd(); const date = new Date().toISOString().substring(0, 10); const filePath = path.join(logPath, `${date}.log`); this.stream = fs.createWriteStream(filePath, { flags: 'a' }); diff --git a/JavaScript/b-transport/logger.js b/JavaScript/b-transport/logger.js index 80b172e..1121d1d 100644 --- a/JavaScript/b-transport/logger.js +++ b/JavaScript/b-transport/logger.js @@ -16,7 +16,7 @@ const DATETIME_LENGTH = 19; class Logger { constructor(logPath) { - this.path = logPath; + this.path = process.cwd(); const date = new Date().toISOString().substring(0, 10); const filePath = path.join(logPath, `${date}.log`); this.stream = fs.createWriteStream(filePath, { flags: 'a' }); diff --git a/JavaScript/c-commonjs/logger.js b/JavaScript/c-commonjs/logger.js index 80b172e..1121d1d 100644 --- a/JavaScript/c-commonjs/logger.js +++ b/JavaScript/c-commonjs/logger.js @@ -16,7 +16,7 @@ const DATETIME_LENGTH = 19; class Logger { constructor(logPath) { - this.path = logPath; + this.path = process.cwd(); const date = new Date().toISOString().substring(0, 10); const filePath = path.join(logPath, `${date}.log`); this.stream = fs.createWriteStream(filePath, { flags: 'a' }); diff --git a/JavaScript/d-messenger/lib/logger.js b/JavaScript/d-messenger/lib/logger.js index 80b172e..e157f65 100644 --- a/JavaScript/d-messenger/lib/logger.js +++ b/JavaScript/d-messenger/lib/logger.js @@ -15,8 +15,8 @@ const COLORS = { const DATETIME_LENGTH = 19; class Logger { - constructor(logPath) { - this.path = logPath; + constructor(logPath, appRootPath) { + this.path = appRootPath; const date = new Date().toISOString().substring(0, 10); const filePath = path.join(logPath, `${date}.log`); this.stream = fs.createWriteStream(filePath, { flags: 'a' }); @@ -69,4 +69,4 @@ class Logger { } } -module.exports = new Logger('./log'); +module.exports = (appRoot) => new Logger('./log', appRoot); diff --git a/JavaScript/d-messenger/main.js b/JavaScript/d-messenger/main.js index 83d5663..44eff1c 100644 --- a/JavaScript/d-messenger/main.js +++ b/JavaScript/d-messenger/main.js @@ -3,7 +3,7 @@ const fsp = require('node:fs').promises; const path = require('node:path'); const staticServer = require('./lib/static.js'); -const logger = require('./lib/logger.js'); +const logger = require('./lib/logger.js')(process.cwd()); const common = require('./lib/common.js'); const config = require('./config.js'); const load = require('./lib/load.js')(config.sandbox);