@youpaichris/logger 6.1.1 → 6.1.3

Sign up to get free protection for your applications and to get access to all the features.
package/index.js CHANGED
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  const {createWriteStreamWithDirectories} = require('./utils.js');
9
+ const {createInterface} = require("node:readline");
9
10
 
10
11
  let logFilePath, logFile, successFilePath, successFile, errorFilePath, errorFile, criticalFilePath, criticalFile;
11
12
 
@@ -227,8 +228,8 @@ class Logger {
227
228
  let pathLine = this?.path ? `[${this.path}:${__line}]` : "Anonymous";
228
229
  loggerConfig.log(consoleStyles['green'][0] + dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date()),
229
230
  consoleStyles['red'][0] + consoleStyles['bold'][0] + "| " +
230
- consoleStyles['bold'][0] + consoleStyles['magenta'][0] + "DEBUG " + consoleStyles['red'][0] + " |" +
231
- consoleStyles['blue'][0], ` ${pathLine.padEnd(22, " ")}${consoleStyles['magenta'][0]}🚧`, consoleStyles['magenta'][0],
231
+ consoleStyles['bold'][0] + consoleStyles['cyan'][0] + "DEBUG " + consoleStyles['red'][0] + " |" +
232
+ consoleStyles['blue'][0], ` ${pathLine.padEnd(22, " ")}${consoleStyles['cyan'][0]}🚧`, consoleStyles['cyan'][0],
232
233
  ...msg,
233
234
  consoleStyles['magenta'][1] + consoleStyles['bold'][1] + '\b'
234
235
  );
@@ -241,8 +242,8 @@ class Logger {
241
242
  let pathLine = this?.path ? `[${this.path}:${__line}]` : "Anonymous";
242
243
  loggerConfig.log(consoleStyles['green'][0] + dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date()),
243
244
  consoleStyles['red'][0] + consoleStyles['bold'][0] + "| " +
244
- consoleStyles['bold'][0] + consoleStyles['cyan'][0] + "CALL " + consoleStyles['red'][0] + " |" +
245
- consoleStyles['blue'][0], ` ${pathLine.padEnd(22, " ")}${consoleStyles['cyan'][0]}🔔`, consoleStyles['cyan'][0],
245
+ consoleStyles['bold'][0] + consoleStyles['magenta'][0] + "CALL " + consoleStyles['red'][0] + " |" +
246
+ consoleStyles['blue'][0], ` ${pathLine.padEnd(22, " ")}${consoleStyles['magenta'][0]}🔔`, consoleStyles['magenta'][0],
246
247
  ...msg,
247
248
  consoleStyles['cyan'][1] + consoleStyles['bold'][1] + '\b'
248
249
  );
@@ -268,6 +269,18 @@ class Logger {
268
269
 
269
270
  };
270
271
 
272
+ async input(prompt) {
273
+ const rl = createInterface({
274
+ input: process.stdin,
275
+ output: process.stdout
276
+ });
277
+ try {
278
+ this.debug(prompt);
279
+ return await new Promise(resolve => rl.question('', resolve));
280
+ } finally {
281
+ rl.close();
282
+ }
283
+ }
271
284
 
272
285
  }
273
286
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youpaichris/logger",
3
- "version": "6.1.1",
3
+ "version": "6.1.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/tests.js CHANGED
@@ -8,7 +8,7 @@
8
8
  * */
9
9
  const Logger = require('./index.js');
10
10
 
11
- const logger = new Logger(true);
11
+ const logger = new Logger();
12
12
 
13
13
  logger.info("info")
14
14
  logger.debug("debug");
@@ -17,4 +17,8 @@ logger.warn("warn");
17
17
  logger.success("success");
18
18
  logger.call("call");
19
19
  logger.critical("critical");
20
- logger.info({name: 1}, {name: 2}, 333);
20
+ logger.info({name: 1}, {name: 2}, 333);
21
+ (async ()=>{
22
+ let e = await logger.input("input something");
23
+ logger.info(e);
24
+ })()
package/utils.js CHANGED
@@ -15,6 +15,7 @@ function createWriteStreamWithDirectories(logFilePath, options = {}) {
15
15
  return fs.createWriteStream(logFilePath, {flags: 'a', ...options});
16
16
  }
17
17
 
18
+
18
19
  module.exports = {
19
- createWriteStreamWithDirectories
20
+ createWriteStreamWithDirectories,
20
21
  }