Created
August 3, 2017 23:59
-
-
Save Daniel-Hug/2b0d9fa597adaff30c8a071181847673 to your computer and use it in GitHub Desktop.
log messages to page maintaining whitespace formatting
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
var log = (function() { | |
function qs(selector, scope) { | |
return (scope || document).querySelector(selector); | |
} | |
var log = qs('#log'); | |
return function(msg) { | |
var p = document.createElement('p'); | |
p.style.whiteSpace = 'pre'; | |
p.textContent = msg; | |
(log || document.body).appendChild(p); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment