Skip to content

Instantly share code, notes, and snippets.

@paustint
Created March 24, 2018 00:06
Show Gist options
  • Save paustint/8fc1084f41e48ac902cb4da8d8bdcdc5 to your computer and use it in GitHub Desktop.
Save paustint/8fc1084f41e48ac902cb4da8d8bdcdc5 to your computer and use it in GitHub Desktop.
// utils.resource
window.utils = ({
SHOW_LOG: true, // Set to false in production
log: function() { },
warn: function() { },
error: function() { },
logInit: function () {
if(this.SHOW_LOG) {
this.log = console.log.bind(console);
this.warn = console.warn.bind(console);
this.error = console.error.bind(console);
}
},
});
// Initialize our log based on the log level
window.utils.logInit();
// This is also a good place to put polyfills so they load automatically when the utils are imported.
// e.x.: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment