Skip to content

Instantly share code, notes, and snippets.

@mishalrai
Created January 22, 2019 08:34
Show Gist options
  • Save mishalrai/c40b5290d03c15a36d9f6d302fabff70 to your computer and use it in GitHub Desktop.
Save mishalrai/c40b5290d03c15a36d9f6d302fabff70 to your computer and use it in GitHub Desktop.
log only dev mode
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