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);