Skip to content

Instantly share code, notes, and snippets.

@aqual3o
Created May 4, 2019 00:40
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 aqual3o/662fc6420df660f540f685ab719cad1b to your computer and use it in GitHub Desktop.
Save aqual3o/662fc6420df660f540f685ab719cad1b to your computer and use it in GitHub Desktop.
Custom logger which can be dynamically turned on/off
/* eslint no-console : off */
const logger = {};
let logOptions = {
enabled : true
};
logger.setConfig = function (options) {
logOptions = options;
};
logger.info = function (...args) {
if (logOptions.enabled)
console.info (...args);
};
logger.error = function (...args) {
if (logOptions.enabled)
console.error (...args);
};
logger.debug = function (...args) {
if (logOptions.enabled)
console.debug (...args);
};
module.exports = logger;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment