Created
June 9, 2020 18:51
-
-
Save mjhenkes/6987362ede963469581cfc43ab418d02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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