Skip to content

Instantly share code, notes, and snippets.

@eliotsykes
Last active March 13, 2017 10:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eliotsykes/1ef7dec6e77e09b6f9cf6c52552f64aa to your computer and use it in GitHub Desktop.
Save eliotsykes/1ef7dec6e77e09b6f9cf6c52552f64aa to your computer and use it in GitHub Desktop.
Logging JavaScript client-side to floating div
// Requires jQuery
var logger = {
setup: function() {
$('<div style="position:fixed; top: 0; left: 0; width: 100%; background-color: white;"><pre id="log-output" style="max-height: 70px; font-size: 10px; line-height: 12px;"></pre></div>')
.appendTo('body');
this.logOutput = $('#log-output');
},
info: function(msg) { this.logOutput.prepend(msg + "\n"); },
hide: function() { this.logOutput.parent().hide(); },
show: function() { this.logOutput.parent().show(); }
};
logger.setup();
logger.info("Something to report...");
//logger.hide();
//logger.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment