Skip to content

Instantly share code, notes, and snippets.

@mjhenkes
Created June 9, 2020 18:51
Show Gist options
  • Select an option

  • Save mjhenkes/6987362ede963469581cfc43ab418d02 to your computer and use it in GitHub Desktop.

Select an option

Save mjhenkes/6987362ede963469581cfc43ab418d02 to your computer and use it in GitHub Desktop.
const LOGGER_ENABLED = process.env.NODE_ENV !== 'production';
const NO_OP = () => {};
/* eslint-disable no-console */
const Logger = {
info: LOGGER_ENABLED ? console.log : NO_OP,
warn: LOGGER_ENABLED ? console.warn : NO_OP,
error: console.error,
};
/* eslint-enable no-console */
const initializeLogger = (onInfo, onWarn, onError) => {
Logger.onInfo = onInfo;
Logger.onWarn = onWarn;
Logger.onError = onError;
};
export default Logger;
export { initializeLogger };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment