-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (25 loc) · 950 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
if (console && console.error) {
console._error = console.error
console.error = (...args) => {
if (args.length > 1 && args[0].substr(-2) === '%s') {
let full = args.shift()
full = full.substr(0, full.length - 2).replace(/ *\n+ */, ' ')
const trace = args.pop()
while (full.indexOf('%s') >= 0 && args.length) {
full = full.replace(/%s/, args.shift())
}
let first = full.indexOf('. ') >= 0 ? full.split('. ')[0] + '.' : full
const type = first.indexOf('Warning: ') === 0 ? 'warn' : '_error'
if (type === 'warn') {
first = first.substr(9)
}
console[type](first)
console._error('[DOMLOG] ' + full, {
trace: trace
.trim()
.split(/ *\n+ */)
.map((a) => a.trim())
})
}
}
}