@bonsaif/bonsaif-wa
Version:
Utileria para poder consumir servicios de WhatsApp CloudApi
51 lines (40 loc) • 1.4 kB
JavaScript
class Logger{
static DEBUG = true;
static log(msg, obj){
if(this.DEBUG){
var hora = new Date();
if(obj == undefined){
obj = "";
}
console.log('' + hora.toLocaleDateString() + ' ' + hora.toLocaleTimeString() + '.' + hora.getMilliseconds() + ' ' + msg, obj);
}
}
error(msg, obj){
var hora = new Date();
if(this.DEBUG){
if(obj == undefined){
obj = "";
}
console.error('' + hora.toLocaleDateString() + ' ' + hora.toLocaleTimeString() + '.' + hora.getMilliseconds() + ' ' + msg, obj);
}
}
info(msg, obj){
var hora = new Date();
if(this.DEBUG){
if(obj == undefined){
obj = "";
}
console.info('' + hora.toLocaleDateString() + ' ' + hora.toLocaleTimeString() + '.' + hora.getMilliseconds() + ' ' + msg, obj);
}
}
warning(msg, obj){
var hora = new Date();
if(this.DEBUG){
if(obj == undefined){
obj = "";
}
console.warning('' + hora.toLocaleDateString() + ' ' + hora.toLocaleTimeString() + '.' + hora.getMilliseconds() + ' ' + msg, obj);
}
}
}
module.exports = Logger;