You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
666 B
28 lines
666 B
const ZERO_WIDTH_CHAR = {
|
|
NOTE: '',
|
|
WARNING: '\u200B',
|
|
ERROR: '\u200C',
|
|
backup0: '\u200D',
|
|
backup1: '\u200E',
|
|
backup2: '\u200F',
|
|
backup3: '\uFEFF'
|
|
}
|
|
|
|
function overridedConsole (name, oldFn, char) {
|
|
console[name] = function (...args) {
|
|
oldFn.apply(this, args.map(arg => {
|
|
let item
|
|
if (typeof arg !== 'object') {
|
|
item = `${char}${arg}${char}`
|
|
} else {
|
|
item = `${char}${JSON.stringify(arg)}${char}`
|
|
}
|
|
|
|
return item
|
|
}))
|
|
}
|
|
}
|
|
if (typeof console !== 'undefined') {
|
|
overridedConsole('warn', console.warn, ZERO_WIDTH_CHAR.WARNING)
|
|
// overridedConsole('error', console.error, ZERO_WIDTH_CHAR.ERROR)
|
|
}
|
|
|