Skip to content

Commit 66a9ba6

Browse files
author
Pooya Parsa
committed
Better playground logs
1 parent 63d677e commit 66a9ba6

File tree

1 file changed

+12
-31
lines changed

1 file changed

+12
-31
lines changed

docs/nuxt/pages/play.vue

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -171,16 +171,16 @@ methods: {
171171
this.originalError = console.error;
172172
const self = this;
173173
174-
console.warn = function (text) {
175-
self.log('warning', text);
174+
console.warn = function () {
175+
self.log('warning', arguments);
176176
};
177177
178-
console.log = function (text) {
179-
self.log('info', text);
178+
console.log = function () {
179+
self.log('info', arguments);
180180
};
181181
182-
console.error = function (text) {
183-
self.log('danger', text);
182+
console.error = function () {
183+
self.log('danger', arguments);
184184
};
185185
}
186186
},
@@ -216,37 +216,18 @@ methods: {
216216
}
217217
},
218218
methods: {
219-
log(tag, text) {
220-
if (!text) {
221-
return;
219+
log(tag, args) {
220+
const argsArr = [tag];
221+
for (let i = 0; i < args.length; i++) {
222+
argsArr.push(args[i]);
222223
}
223224
224-
if (!text.indexOf) {
225-
text = String(text);
226-
}
227-
228-
if (text.indexOf('[HMR]') !== -1) {
229-
return;
230-
}
231-
232-
// There is a bug when having more than 2 vue instances in detecting mutations.
233-
if (text.indexOf('Avoid mutating a prop directly') !== -1) {
234-
return;
235-
}
236-
237-
if (text.indexOf('[Vue warn]') !== -1) {
238-
tag = 'warning';
239-
}
240-
241-
text = text.replace('[Vue warn]: ', '');
225+
this.originalLog.apply(console, argsArr);
242226
243227
if (this.messages.length > 10) {
244228
this.messages.splice(10);
245229
}
246-
247-
this.originalLog(text);
248-
249-
this.messages.unshift([tag, text]);
230+
this.messages.unshift([argsArr.shift(), argsArr.map(JSON.stringify).join(' ')]);
250231
},
251232
run() {
252233
// Commit latest changes

0 commit comments

Comments
 (0)