@youpaichris/logger 6.1.2 → 6.1.4

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
 
@@ -52,7 +53,7 @@ Object.defineProperty(global, '__stack', {
52
53
  Object.defineProperty(global, '__line', {
53
54
  get: function () {
54
55
  const stack = new Error().stack.split('\n').slice(2);
55
- const caller = stack[1].trim();
56
+ const caller = stack[1].includes(`@youpaichris/logger/index.js`) ? stack[2] .trim() : stack[1].trim();
56
57
  const index = caller.indexOf('at ') + 3;
57
58
  const clean = caller.slice(index);
58
59
  const parts = clean.split(':');
@@ -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.2",
3
+ "version": "6.1.4",
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
  }