@youpaichris/logger 6.1.0 → 6.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/index.js +7 -8
  2. package/package.json +1 -1
  3. package/tests.js +2 -1
package/index.js CHANGED
@@ -140,7 +140,6 @@ class Logger {
140
140
  }
141
141
 
142
142
  initLogPath() {
143
-
144
143
  let e = process.platform === `win32` ? __filename.split("\\") : __filename.split("/");
145
144
  let path = e.slice(0, e.indexOf("node_modules")).join("/");
146
145
  logFilePath = e.at(e.indexOf("node_modules") - 1) === 'logger' ? `log.log` : e.at(e.indexOf("node_modules") - 1) + `.log`;
@@ -170,7 +169,7 @@ class Logger {
170
169
  ...msg,
171
170
  consoleStyles['blue'][1] + consoleStyles['bold'][1] + '\b'
172
171
  );
173
- this.save && logFile.write(`${dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date())} | INFO | ${pathLine.padEnd(22, " ")}${[...msg]}` + '\n');
172
+ this.save && logFile.write(`${dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date())} | INFO | ${pathLine.padEnd(22, " ")}${msg.map(e => typeof e === 'object' ? JSON.stringify(e) : e).join(" ")}` + '\n');
174
173
  };
175
174
 
176
175
  warn(...msg) {
@@ -183,7 +182,7 @@ class Logger {
183
182
  ...msg,
184
183
  consoleStyles['yellow'][1] + consoleStyles['bold'][1] + '\b'
185
184
  );
186
- this.save && logFile.write(`${dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date())} | WARNING | ${pathLine.padEnd(22, " ")}${[...msg]}` + '\n');
185
+ this.save && logFile.write(`${dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date())} | WARNING | ${pathLine.padEnd(22, " ")}${msg.map(e => typeof e === 'object' ? JSON.stringify(e) : e).join(" ")}` + '\n');
187
186
  };
188
187
 
189
188
  error(...msg) {
@@ -197,7 +196,7 @@ class Logger {
197
196
  consoleStyles['red'][1] + consoleStyles['bold'][1] + '\b'
198
197
  );
199
198
  if (this.save) {
200
- let _msg = `${dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date())} | ERROR | ${pathLine.padEnd(22, " ")}${[...msg]}` + '\n';
199
+ let _msg = `${dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date())} | ERROR | ${pathLine.padEnd(22, " ")}${msg.map(e => typeof e === 'object' ? JSON.stringify(e) : e).join(" ")}` + '\n';
201
200
  logFile.write(_msg);
202
201
  errorFile.write(_msg);
203
202
  }
@@ -215,7 +214,7 @@ class Logger {
215
214
  consoleStyles['green'][1] + consoleStyles['bold'][1] + '\b'
216
215
  );
217
216
  if (this.save) {
218
- let _msg = `${dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date())} | SUCCESS | ${pathLine.padEnd(22, " ")}${[...msg]}` + '\n';
217
+ let _msg = `${dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date())} | SUCCESS | ${pathLine.padEnd(22, " ")}${msg.map(e => typeof e === 'object' ? JSON.stringify(e) : e).join(" ")}` + '\n';
219
218
  logFile.write(_msg);
220
219
  successFile.write(_msg);
221
220
  }
@@ -233,7 +232,7 @@ class Logger {
233
232
  ...msg,
234
233
  consoleStyles['magenta'][1] + consoleStyles['bold'][1] + '\b'
235
234
  );
236
- this.save && logFile.write(`${dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date())} | DEBUG | ${pathLine.padEnd(22, " ")}${[...msg]}` + '\n');
235
+ this.save && logFile.write(`${dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date())} | DEBUG | ${pathLine.padEnd(22, " ")}${msg.map(e => typeof e === 'object' ? JSON.stringify(e) : e).join(" ")}` + '\n');
237
236
 
238
237
  };
239
238
 
@@ -247,7 +246,7 @@ class Logger {
247
246
  ...msg,
248
247
  consoleStyles['cyan'][1] + consoleStyles['bold'][1] + '\b'
249
248
  );
250
- this.save && logFile.write(`${dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date())} | CALL | ${pathLine.padEnd(22, " ")}${[...msg]}` + '\n');
249
+ this.save && logFile.write(`${dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date())} | CALL | ${pathLine.padEnd(22, " ")}${msg.map(e => typeof e === 'object' ? JSON.stringify(e) : e).join(" ")}` + '\n');
251
250
 
252
251
  };
253
252
 
@@ -262,7 +261,7 @@ class Logger {
262
261
  consoleStyles['redBG'][1] + consoleStyles['bold'][1] + '\b', consoleStyles['redBG'][1] + consoleStyles['bold'][1] + '\b'
263
262
  );
264
263
  if (this.save) {
265
- let _msg = `${dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date())} | CRITICAL| ${pathLine.padEnd(22, " ")}${[...msg]}` + '\n';
264
+ let _msg = `${dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date())} | CRITICAL| ${pathLine.padEnd(22, " ")}${msg.map(e => typeof e === 'object' ? JSON.stringify(e) : e).join(" ")}` + '\n';
266
265
  logFile.write(_msg);
267
266
  criticalFile.write(_msg);
268
267
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youpaichris/logger",
3
- "version": "6.1.0",
3
+ "version": "6.1.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/tests.js CHANGED
@@ -16,4 +16,5 @@ logger.error("error");
16
16
  logger.warn("warn");
17
17
  logger.success("success");
18
18
  logger.call("call");
19
- logger.critical("critical");
19
+ logger.critical("critical");
20
+ logger.info({name: 1}, {name: 2}, 333);