Skip to content

Instantly share code, notes, and snippets.

@egyjs
Created August 9, 2017 07:43
Show Gist options
  • Save egyjs/9c2934828d7470a4b89bd94bd4ab67d9 to your computer and use it in GitHub Desktop.
Save egyjs/9c2934828d7470a4b89bd94bd4ab67d9 to your computer and use it in GitHub Desktop.
get all console.log in div
$("body").append('<ul style="background: #000; border: 3px groove #ccc; color: #ccc; display: block; width: 99%; height: 60px; overflow: scroll; margin: 0 auto; position: fixed; bottom: 0;" id="EL-console"></ul>');
function htmlEncode(value){
return $('<ul/>').text(value).html();
}
var former = console.log;
console.log = function(msg){
former(msg);
$("#EL-console").append("<li class='te'>" + msg + "</li>");
$('.te:empty').remove();
}
window.onerror = function(message, url, linenumber) {
console.log('<li class="EL-logError">'+"JavaScript error: " + message + " on line " +
linenumber + " for " + url + '</li>');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment