Created
September 25, 2014 13:55
-
-
Save jeromeetienne/59becf48e52a1354a867 to your computer and use it in GitHub Desktop.
console.log to screen - nice to debug mobile
This file contains 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
////////////////////////////////////////////////////////////////////////////////// | |
// console.log to screen | |
////////////////////////////////////////////////////////////////////////////////// | |
;(function(){ | |
var container = document.createElement('div') | |
container.dataset.name = 'consoleLogOnScreen' | |
container.style.width = '100%'; | |
container.style.height = '100%'; | |
container.style.position = 'absolute'; | |
container.style.fontSize = '100%'; | |
container.style.margin = '1em'; | |
container.style.pointerEvents = 'none' | |
container.style.zIndex = 1000 | |
document.body.insertBefore(container, document.body.firstChild) | |
console.log = function(){ | |
var args = Array.prototype.slice.call(arguments, 0); | |
var text = args.join(' ') | |
text = '[' + /\d\d\:\d\d\:\d\d/.exec( new Date() )[ 0 ] + '] ' + text | |
var line = document.createElement('div') | |
line.innerText = text | |
// container.insertBefore(line, container.firstChild) | |
container.appendChild(line) | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment