Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Last active August 29, 2015 14:17
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 ramnathv/ea8f5a614703b833880e to your computer and use it in GitHub Desktop.
Save ramnathv/ea8f5a614703b833880e to your computer and use it in GitHub Desktop.
// Debug on localhost
var host = window.location.hostname;
var debug = host.match(/localhost|127.0.0.1|staging.example.com/);
// Safely log things, if need be
function log() {
if (debug && console && typeof console.log === 'function') {
for (var i = 0, ii = arguments.length; i < ii; i++) {
console.log(arguments[i]);
}
}
}
// This will do nothing, in production
log('Testing, testing...');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment