@youpaichris/logger 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +12 -12
- package/package.json +1 -1
package/index.js
CHANGED
@@ -4,20 +4,20 @@
|
|
4
4
|
* Chris / QQ:10512
|
5
5
|
*/
|
6
6
|
|
7
|
-
const
|
8
|
-
|
7
|
+
const __log = console.log;
|
8
|
+
const __log__ = function () {
|
9
9
|
if (arguments[3] === '\x1B[41m') {
|
10
10
|
arguments[4] = "\b" + arguments[4];
|
11
11
|
arguments[arguments.length-1] += consoleStyles['redBG'][1] + consoleStyles['bold'][1] + '\b';
|
12
12
|
}
|
13
|
-
return
|
13
|
+
return __log.apply(this, arguments)
|
14
14
|
}
|
15
15
|
const loggerConfig = {
|
16
16
|
Date: (() => {
|
17
17
|
return Date
|
18
18
|
})(),
|
19
|
-
|
20
|
-
return
|
19
|
+
log: (() => {
|
20
|
+
return __log__
|
21
21
|
})(),
|
22
22
|
Error: (() => {
|
23
23
|
return Error
|
@@ -121,7 +121,7 @@ class Logger {
|
|
121
121
|
|
122
122
|
info(...msg) {
|
123
123
|
let pathLine = this?.path ? `[${this.path}:${__line}]` : "Anonymous";
|
124
|
-
loggerConfig.
|
124
|
+
loggerConfig.log(consoleStyles['green'][0] + dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date()),
|
125
125
|
consoleStyles['red'][0] + consoleStyles['bold'][0] + "| " +
|
126
126
|
consoleStyles['bold'][0] + consoleStyles['blue'][0] + "INFO " + consoleStyles['red'][0] + " |" +
|
127
127
|
consoleStyles['blue'][0], ` ${pathLine.padEnd(22, " ")}${consoleStyles['blue'][0]}📡`, consoleStyles['blue'][0],
|
@@ -132,7 +132,7 @@ class Logger {
|
|
132
132
|
|
133
133
|
warn(...msg) {
|
134
134
|
let pathLine = this?.path ? `[${this.path}:${__line}]` : "Anonymous";
|
135
|
-
loggerConfig.
|
135
|
+
loggerConfig.log(consoleStyles['green'][0] + dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date()),
|
136
136
|
consoleStyles['red'][0] + consoleStyles['bold'][0] + "| " +
|
137
137
|
consoleStyles['bold'][0] + consoleStyles['yellow'][0] + "WARNING " + consoleStyles['red'][0] + " |" +
|
138
138
|
consoleStyles['blue'][0], ` ${pathLine.padEnd(22, " ")}${consoleStyles['yellow'][0]}💡`, consoleStyles['yellow'][0],
|
@@ -143,7 +143,7 @@ class Logger {
|
|
143
143
|
|
144
144
|
error(...msg) {
|
145
145
|
let pathLine = this?.path ? `[${this.path}:${__line}]` : "Anonymous";
|
146
|
-
loggerConfig.
|
146
|
+
loggerConfig.log(consoleStyles['green'][0] + dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date()),
|
147
147
|
consoleStyles['red'][0] + consoleStyles['bold'][0] + "| " +
|
148
148
|
consoleStyles['bold'][0] + consoleStyles['red'][0] + "ERROR " + consoleStyles['red'][0] + " |" +
|
149
149
|
consoleStyles['blue'][0], ` ${pathLine.padEnd(22, " ")}${consoleStyles['red'][0]}🚨`, consoleStyles['red'][0],
|
@@ -154,7 +154,7 @@ class Logger {
|
|
154
154
|
|
155
155
|
success(...msg) {
|
156
156
|
let pathLine = this?.path ? `[${this.path}:${__line}]` : "Anonymous";
|
157
|
-
loggerConfig.
|
157
|
+
loggerConfig.log(consoleStyles['green'][0] + dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date()),
|
158
158
|
consoleStyles['red'][0] + consoleStyles['bold'][0] + "| " +
|
159
159
|
consoleStyles['bold'][0] + consoleStyles['green'][0] + "SUCCESS " + consoleStyles['red'][0] + " |" +
|
160
160
|
consoleStyles['blue'][0], ` ${pathLine.padEnd(22, " ")}${consoleStyles['green'][0]}🎯`, consoleStyles['green'][0],
|
@@ -165,7 +165,7 @@ class Logger {
|
|
165
165
|
|
166
166
|
debug(...msg) {
|
167
167
|
let pathLine = this?.path ? `[${this.path}:${__line}]` : "Anonymous";
|
168
|
-
loggerConfig.
|
168
|
+
loggerConfig.log(consoleStyles['green'][0] + dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date()),
|
169
169
|
consoleStyles['red'][0] + consoleStyles['bold'][0] + "| " +
|
170
170
|
consoleStyles['bold'][0] + consoleStyles['magenta'][0] + "DEBUG " + consoleStyles['red'][0] + " |" +
|
171
171
|
consoleStyles['blue'][0], ` ${pathLine.padEnd(22, " ")}${consoleStyles['magenta'][0]}🚧`, consoleStyles['magenta'][0],
|
@@ -176,7 +176,7 @@ class Logger {
|
|
176
176
|
|
177
177
|
call(...msg) {
|
178
178
|
let pathLine = this?.path ? `[${this.path}:${__line}]` : "Anonymous";
|
179
|
-
loggerConfig.
|
179
|
+
loggerConfig.log(consoleStyles['green'][0] + dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date()),
|
180
180
|
consoleStyles['red'][0] + consoleStyles['bold'][0] + "| " +
|
181
181
|
consoleStyles['bold'][0] + consoleStyles['cyan'][0] + "CALL " + consoleStyles['red'][0] + " |" +
|
182
182
|
consoleStyles['blue'][0], ` ${pathLine.padEnd(22, " ")}${consoleStyles['cyan'][0]}🔔`, consoleStyles['cyan'][0],
|
@@ -187,7 +187,7 @@ class Logger {
|
|
187
187
|
|
188
188
|
critical(...msg) {
|
189
189
|
let pathLine = this?.path ? `[${this.path}:${__line}]` : "Anonymous";
|
190
|
-
loggerConfig.
|
190
|
+
loggerConfig.log(consoleStyles['green'][0] + dateFormat("YYYY-mm-dd HH:MM:SS.ms", new loggerConfig.Date()),
|
191
191
|
consoleStyles['red'][0] + consoleStyles['bold'][0] + "| " +
|
192
192
|
consoleStyles['bold'][0] + consoleStyles['redBG'][0] + consoleStyles['white'][0] + "CRITICAL" + consoleStyles['redBG'][1] + consoleStyles['red'][0] + " |" +
|
193
193
|
consoleStyles['blue'][0], ` ${pathLine.padEnd(22, " ")}${consoleStyles['cyan'][0]}🔴 ${consoleStyles['white'][0]}`, consoleStyles['redBG'][0],
|