Created
September 16, 2021 06:54
-
-
Save ssddi456/ff15a5bd7f15e5a54d868cf92e0a7aa6 to your computer and use it in GitHub Desktop.
for add some easy to see log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function logRemote() { | |
const img = new Image(); | |
window.log_img = window.log_img || []; | |
window.log_img.push(img); | |
const content = []; | |
for (let index = 0; index < arguments.length; index++) { | |
const element = arguments[index]; | |
content.push('n[]=' + JSON.stringify(element)); | |
} | |
img.src = 'https://127.0.0.1:8888/log?' + content.join('&'); | |
} | |
const logger = document.getElementById('log'); | |
function logLocal() { | |
const content = []; | |
for (let index = 0; index < arguments.length; index++) { | |
const element = arguments[index]; | |
content.push('n[]=' + | |
((function (){try { | |
return JSON.stringify(element); | |
} catch (error) { | |
return error.message; | |
}})())); | |
} | |
const log = document.createElement('div'); | |
log.innerText = content.join(' '); | |
logger.appendChild(log); | |
} | |
window.onerror = function (e) { | |
logLocal('error', e); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment