traverson
Version:
Hypermedia API/HATEOAS client for Node.js and the browser
50 lines (39 loc) • 861 B
JavaScript
;
// TODO Replace by a proper lightweight logging module, suited for the browser
var enabled = false;
function Logger(id) {
if (id == null) {
id = '';
}
this.id = id;
}
Logger.prototype.enable = function() {
this.enabled = true;
};
Logger.prototype.debug = function(message) {
if (enabled) {
console.log(this.id + '/debug: ' + message);
}
};
Logger.prototype.info = function(message) {
if (enabled) {
console.log(this.id + '/info: ' + message);
}
};
Logger.prototype.warn = function(message) {
if (enabled) {
console.log(this.id + '/warn: ' + message);
}
};
Logger.prototype.error = function(message) {
if (enabled) {
console.log(this.id + '/error: ' + message);
}
};
function minilog(id) {
return new Logger(id);
}
minilog.enable = function() {
enabled = true;
};
module.exports = minilog;