rightfe
Version:
the front-end-engineer tool
39 lines (33 loc) • 773 B
JavaScript
module.exports = {
debug: false,
setup: function(options) {
if (options && options.debug) {
return this.debug = true;
}
},
start: function() {
return this._tick = new Date();
},
stop: function() {
return (new Date().getTime() - this._tick.getTime()) + 'ms';
},
trace: function() {
if (!this.debug) {
return;
}
return this.to('[TRACE] ', Array.prototype.join.call(arguments,
' '));
},
error: function() {
return this.to('[ERROR] ', Array.prototype.join.call(arguments,
' '));
},
log: function() {
return this.to('[LOG] ', Array.prototype.join.call(arguments, ' '));
},
to: function() {
var n;
n = Array.prototype.join.call(arguments, '');
return console.info(n);
}
}