@youpaichris/logger 6.1.0 → 6.1.2
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +11 -12
- package/package.json +1 -1
- 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, " ")}${
|
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, " ")}${
|
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, " ")}${
|
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, " ")}${
|
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
|
}
|
@@ -228,12 +227,12 @@ class Logger {
|
|
228
227
|
let pathLine = this?.path ? `[${this.path}:${__line}]` : "Anonymous";
|
229
228
|
loggerConfig.log(consoleStyles['green'][0] + dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date()),
|
230
229
|
consoleStyles['red'][0] + consoleStyles['bold'][0] + "| " +
|
231
|
-
consoleStyles['bold'][0] + consoleStyles['
|
232
|
-
consoleStyles['blue'][0], ` ${pathLine.padEnd(22, " ")}${consoleStyles['
|
230
|
+
consoleStyles['bold'][0] + consoleStyles['cyan'][0] + "DEBUG " + consoleStyles['red'][0] + " |" +
|
231
|
+
consoleStyles['blue'][0], ` ${pathLine.padEnd(22, " ")}${consoleStyles['cyan'][0]}🚧`, consoleStyles['cyan'][0],
|
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, " ")}${
|
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
|
|
@@ -242,12 +241,12 @@ class Logger {
|
|
242
241
|
let pathLine = this?.path ? `[${this.path}:${__line}]` : "Anonymous";
|
243
242
|
loggerConfig.log(consoleStyles['green'][0] + dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date()),
|
244
243
|
consoleStyles['red'][0] + consoleStyles['bold'][0] + "| " +
|
245
|
-
consoleStyles['bold'][0] + consoleStyles['
|
246
|
-
consoleStyles['blue'][0], ` ${pathLine.padEnd(22, " ")}${consoleStyles['
|
244
|
+
consoleStyles['bold'][0] + consoleStyles['magenta'][0] + "CALL " + consoleStyles['red'][0] + " |" +
|
245
|
+
consoleStyles['blue'][0], ` ${pathLine.padEnd(22, " ")}${consoleStyles['magenta'][0]}🔔`, consoleStyles['magenta'][0],
|
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, " ")}${
|
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, " ")}${
|
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
package/tests.js
CHANGED