modality-kit 0.1.4 → 0.1.6
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.
- package/dist/index.js +46 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -113,54 +113,78 @@ class ModalityLogger {
|
|
|
113
113
|
if (categroy) {
|
|
114
114
|
prefix += ` [${categroy}]`;
|
|
115
115
|
}
|
|
116
|
-
|
|
117
|
-
`);
|
|
118
|
-
console.log(prefix);
|
|
119
|
-
return payload;
|
|
116
|
+
return { prefix, result: payload };
|
|
120
117
|
}
|
|
121
118
|
log(level, payload, categroy) {
|
|
122
119
|
if (!this.shouldLog(level))
|
|
123
120
|
return;
|
|
124
|
-
const
|
|
121
|
+
const { prefix, result } = this.format(level, payload, categroy);
|
|
125
122
|
switch (level) {
|
|
126
123
|
case "debug":
|
|
127
|
-
console.debug(
|
|
124
|
+
console.debug(`
|
|
125
|
+
`, prefix, result, `
|
|
126
|
+
`);
|
|
128
127
|
break;
|
|
129
128
|
case "info":
|
|
130
|
-
console.
|
|
129
|
+
console.log(`
|
|
130
|
+
`, prefix);
|
|
131
|
+
console.dir(result, {
|
|
131
132
|
depth: null,
|
|
132
133
|
colors: true,
|
|
133
134
|
maxArrayLength: null
|
|
134
135
|
});
|
|
136
|
+
console.log(`
|
|
137
|
+
`);
|
|
135
138
|
break;
|
|
136
139
|
case "warn":
|
|
137
|
-
console.
|
|
140
|
+
console.log(`
|
|
141
|
+
`, prefix);
|
|
142
|
+
console.warn(result);
|
|
143
|
+
console.log(`
|
|
144
|
+
`);
|
|
138
145
|
break;
|
|
139
146
|
case "error":
|
|
140
|
-
const error =
|
|
147
|
+
const error = result.error;
|
|
141
148
|
if (error instanceof Error) {
|
|
142
|
-
delete
|
|
149
|
+
delete result.error;
|
|
143
150
|
const { message, stack } = error;
|
|
144
|
-
if (message) {
|
|
145
|
-
formatted.error = message;
|
|
146
|
-
}
|
|
147
|
-
console.error(formatted);
|
|
148
151
|
if (stack) {
|
|
149
|
-
|
|
152
|
+
if (Object.keys(result).length) {
|
|
153
|
+
console.error(`
|
|
154
|
+
`, prefix, result, `
|
|
155
|
+
`, stack, `
|
|
156
|
+
`);
|
|
157
|
+
} else {
|
|
158
|
+
console.error(`
|
|
159
|
+
`, prefix, `
|
|
160
|
+
`, stack, `
|
|
161
|
+
`);
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
if (message) {
|
|
165
|
+
result.error = message;
|
|
166
|
+
}
|
|
167
|
+
console.error(`
|
|
168
|
+
`, prefix, result, `
|
|
169
|
+
`);
|
|
150
170
|
}
|
|
151
171
|
} else {
|
|
152
|
-
console.error(
|
|
172
|
+
console.error(`
|
|
173
|
+
`, prefix, result, `
|
|
174
|
+
`);
|
|
153
175
|
}
|
|
154
176
|
break;
|
|
155
177
|
case "success":
|
|
156
|
-
console.log(
|
|
178
|
+
console.log(`
|
|
179
|
+
`, prefix, result, `
|
|
180
|
+
`);
|
|
157
181
|
break;
|
|
158
182
|
default:
|
|
159
|
-
console.log(
|
|
183
|
+
console.log(`
|
|
184
|
+
`, prefix, result, `
|
|
185
|
+
`);
|
|
160
186
|
break;
|
|
161
187
|
}
|
|
162
|
-
console.log(`
|
|
163
|
-
`);
|
|
164
188
|
}
|
|
165
189
|
cook(message, data) {
|
|
166
190
|
const payload = typeof message === "string" ? { message } : message;
|
|
@@ -179,8 +203,8 @@ class ModalityLogger {
|
|
|
179
203
|
this.log("warn", this.cook(message, data));
|
|
180
204
|
}
|
|
181
205
|
error(message, error, additionalData) {
|
|
182
|
-
const payload = {
|
|
183
|
-
this.log("error", this.cook(payload, additionalData));
|
|
206
|
+
const payload = { error };
|
|
207
|
+
this.log("error", this.cook(payload, additionalData), message);
|
|
184
208
|
}
|
|
185
209
|
success(message, data) {
|
|
186
210
|
this.log("success", this.cook(message, data));
|
package/package.json
CHANGED