Skip to content

Instantly share code, notes, and snippets.

@jackbrown
Created May 12, 2014 04:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackbrown/072ad21d03566e75271c to your computer and use it in GitHub Desktop.
Save jackbrown/072ad21d03566e75271c to your computer and use it in GitHub Desktop.
A simple web console wrapper
/**
* A simple wrapper for the window.console object
*
* TODO: allow string substitutions: https://developer.mozilla.org/en-US/docs/Web/API/console#Using_string_substitutions
*/
var loggy = (function () {
var debug = true;
this.info = function(msg){
if(debug && window.console && window.console.info){
console.info(msg);
}
}
this.error = function(msg){
if(debug && window.console && window.console.error){
console.error(msg);
}
}
this.log = function(msg){
if(debug && window.console && window.console.log){
console.log(msg);
}
}
this.warn = function(msg){
if(debug && window.console && window.console.warn){
console.warn(msg);
}
}
return this;
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment