modality-kit 0.1.4 → 0.1.5
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 +44 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -113,54 +113,76 @@ 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, stack, `
|
|
155
|
+
`);
|
|
156
|
+
} else {
|
|
157
|
+
console.error(`
|
|
158
|
+
`, prefix, stack, `
|
|
159
|
+
`);
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
if (message) {
|
|
163
|
+
result.error = message;
|
|
164
|
+
}
|
|
165
|
+
console.error(`
|
|
166
|
+
`, prefix, result, `
|
|
167
|
+
`);
|
|
150
168
|
}
|
|
151
169
|
} else {
|
|
152
|
-
console.error(
|
|
170
|
+
console.error(`
|
|
171
|
+
`, prefix, result, `
|
|
172
|
+
`);
|
|
153
173
|
}
|
|
154
174
|
break;
|
|
155
175
|
case "success":
|
|
156
|
-
console.log(
|
|
176
|
+
console.log(`
|
|
177
|
+
`, prefix, result, `
|
|
178
|
+
`);
|
|
157
179
|
break;
|
|
158
180
|
default:
|
|
159
|
-
console.log(
|
|
181
|
+
console.log(`
|
|
182
|
+
`, prefix, result, `
|
|
183
|
+
`);
|
|
160
184
|
break;
|
|
161
185
|
}
|
|
162
|
-
console.log(`
|
|
163
|
-
`);
|
|
164
186
|
}
|
|
165
187
|
cook(message, data) {
|
|
166
188
|
const payload = typeof message === "string" ? { message } : message;
|
|
@@ -179,8 +201,8 @@ class ModalityLogger {
|
|
|
179
201
|
this.log("warn", this.cook(message, data));
|
|
180
202
|
}
|
|
181
203
|
error(message, error, additionalData) {
|
|
182
|
-
const payload = {
|
|
183
|
-
this.log("error", this.cook(payload, additionalData));
|
|
204
|
+
const payload = { error };
|
|
205
|
+
this.log("error", this.cook(payload, additionalData), message);
|
|
184
206
|
}
|
|
185
207
|
success(message, data) {
|
|
186
208
|
this.log("success", this.cook(message, data));
|
package/package.json
CHANGED