Skip to content

Instantly share code, notes, and snippets.

@codeeshop-oc
Created June 13, 2022 07:28
Show Gist options
  • Save codeeshop-oc/14d055b7e013c9522f1264ee77ca0351 to your computer and use it in GitHub Desktop.
Save codeeshop-oc/14d055b7e013c9522f1264ee77ca0351 to your computer and use it in GitHub Desktop.
controlling logger for production mode
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