Created
June 13, 2022 07:28
-
-
Save codeeshop-oc/14d055b7e013c9522f1264ee77ca0351 to your computer and use it in GitHub Desktop.
controlling logger for production mode
This file contains 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
window.logger = function (logLevel, ...args) { | |
// condition: adding to show only logs only when debugging is enabled | |
if(!process.env.PROD) { | |
if(!['error', 'log', 'info', 'warn'].includes(logLevel)) { | |
logLevel = 'error' | |
} | |
console[logLevel](...args) | |
} | |
} | |
logger('log', 'console log called') | |
logger('log', 'arg 1', 'arg 2', 'arg N') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment