Last active
March 13, 2017 10:53
-
-
Save eliotsykes/1ef7dec6e77e09b6f9cf6c52552f64aa to your computer and use it in GitHub Desktop.
Logging JavaScript client-side to floating div
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
// 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