Skip to content

Instantly share code, notes, and snippets.

@Daniel-Hug
Created August 3, 2017 23:59
Show Gist options
  • Save Daniel-Hug/2b0d9fa597adaff30c8a071181847673 to your computer and use it in GitHub Desktop.
Save Daniel-Hug/2b0d9fa597adaff30c8a071181847673 to your computer and use it in GitHub Desktop.
log messages to page maintaining whitespace formatting
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