@youpaichris/logger 6.1.2 → 6.1.3
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +13 -0
- package/package.json +1 -1
- package/tests.js +6 -2
- package/utils.js +2 -1
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
|
|
@@ -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
package/tests.js
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
* */
|
9
9
|
const Logger = require('./index.js');
|
10
10
|
|
11
|
-
const logger = new Logger(
|
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