Created
January 22, 2019 08:34
-
-
Save mishalrai/c40b5290d03c15a36d9f6d302fabff70 to your computer and use it in GitHub Desktop.
log only dev 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
const bg = { | |
devMode : BGJOBFINDER.devMode === 'dev'? true : false, | |
type: 'log', | |
log(...params){ | |
this.common(...params); | |
}, | |
info( ...params ){ | |
this.type = 'info'; | |
this.common(...params); | |
}, | |
error(...params){ | |
this.type = 'error'; | |
this.common(...params); | |
}, | |
warning(...params){ | |
this.type = 'warning'; | |
this.common( ...params); | |
}, | |
common( ...params ){ | |
if(!this.devMode){return false;} | |
switch(this.type){ | |
case 'info': | |
console.info(...params); | |
break; | |
case 'error': | |
console.error(...params); | |
break; | |
case 'warning': | |
console.warn(...params); | |
break; | |
default: | |
console.log(...params); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment