Skip to content

Instantly share code, notes, and snippets.

@codyromano
Created May 12, 2014 14:15
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 codyromano/94cd8c25d1cec1e45c16 to your computer and use it in GitHub Desktop.
Save codyromano/94cd8c25d1cec1e45c16 to your computer and use it in GitHub Desktop.
/**
* An alias for console.log. Only logs messages if the browser
* supports 'console' and the script is running in a dev environment.
*
* @param {Mixed} Any number of arguments
* @return {Undefined}
*/
var safeLog = (function(){
var url = window.location.href,
logAllowed = url.indexOf('8888') > -1 && window.console;
return function(){
if (logAllowed) console.log.apply(console, arguments);
};
})();
// E.g.
safeLog('mytest', {test: 'testing'}, ['another', 'test']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment