Skip to content

Instantly share code, notes, and snippets.

@jeromeetienne
Created September 25, 2014 13:55
Show Gist options
  • Save jeromeetienne/59becf48e52a1354a867 to your computer and use it in GitHub Desktop.
Save jeromeetienne/59becf48e52a1354a867 to your computer and use it in GitHub Desktop.
console.log to screen - nice to debug mobile
//////////////////////////////////////////////////////////////////////////////////
// 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