@youpaichris/logger 6.2.6 → 6.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +18 -2
  2. package/package.json +5 -2
package/index.js CHANGED
@@ -7,6 +7,7 @@
7
7
 
8
8
  const {createWriteStreamWithDirectories} = require('./utils.js');
9
9
  const {createInterface} = require("node:readline");
10
+ const gradient = require('gradient-string');
10
11
 
11
12
  let logFilePath, logFile, successFilePath, successFile, errorFilePath, errorFile, criticalFilePath, criticalFile;
12
13
 
@@ -270,13 +271,28 @@ class Logger {
270
271
 
271
272
  };
272
273
 
273
- async input(...prompt) {
274
+ rainbow(...msg) {
275
+ msg = gradient.rainbow(msg.join(" "));
276
+ this.#prefix && msg.unshift(this.#prefix);
277
+ let pathLine = this?.path ? `[${this.path}:${__line}]` : "Anonymous";
278
+ loggerConfig.log(consoleStyles['green'][0] + dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date()),
279
+ consoleStyles['red'][0] + consoleStyles['bold'][0] + "| " +
280
+ consoleStyles['bold'][0] + consoleStyles['cyan'][0] + gradient.pastel("RAINBOW ") + consoleStyles['red'][0] + " |" +
281
+ consoleStyles['blue'][0], ` ${pathLine.padEnd(24, " ")}${consoleStyles['cyan'][0]}🌈`, consoleStyles['cyan'][0],
282
+ msg,
283
+ consoleStyles['magenta'][1] + consoleStyles['bold'][1] + '\b'
284
+ );
285
+ this.save && logFile.write(`${dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date())} | DEBUG | ${pathLine.padEnd(24, " ")}${msg.map(e => typeof e === 'object' ? JSON.stringify(e) : e).join(" ")}` + '\n');
286
+
287
+ };
288
+
289
+ async input(prompt) {
274
290
  const rl = createInterface({
275
291
  input: process.stdin,
276
292
  output: process.stdout
277
293
  });
278
294
  try {
279
- prompt.length === 0 ? this.debug("Please input:") : this.debug(...prompt);
295
+ this.debug(prompt);
280
296
  return await new Promise(resolve => rl.question('', resolve));
281
297
  } finally {
282
298
  rl.close();
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@youpaichris/logger",
3
- "version": "6.2.6",
3
+ "version": "6.2.7",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
8
8
  },
9
9
  "author": "",
10
- "license": "ISC"
10
+ "license": "ISC",
11
+ "dependencies": {
12
+ "gradient-string": "^2.0.2"
13
+ }
11
14
  }