prism-logger
Version:
beautified logging in nodejs
93 lines (92 loc) • 3.11 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConsoleLogger = void 0;
var ConsoleLogger = /** @class */ (function () {
function ConsoleLogger(debug) {
if (debug === void 0) { debug = false; }
this.debug = false;
this.debug = debug;
if (this.debug) {
this.log("Logging enabled");
}
else {
this.log("Logging disabled");
}
this.log("Logger instance created");
}
ConsoleLogger.prototype.log = function (text, color) {
if (color === void 0) { color = "black"; }
if (this.debug) {
console.log("%c ".concat(text), "color: ".concat(color, ";"));
}
};
ConsoleLogger.prototype.error = function (text) {
this.log(text, "red");
};
ConsoleLogger.prototype.success = function (text) {
this.log(text, "green");
};
ConsoleLogger.prototype.warning = function (text) {
this.log(text, "yellow");
};
ConsoleLogger.prototype.red = function (text) {
this.log(text, "red");
};
ConsoleLogger.prototype.green = function (text) {
this.log(text, "green");
};
ConsoleLogger.prototype.yellow = function (text) {
this.log(text, "yellow");
};
ConsoleLogger.prototype.blue = function (text) {
this.log(text, "blue");
};
ConsoleLogger.prototype.magenta = function (text) {
this.log(text, "magenta");
};
ConsoleLogger.prototype.cyan = function (text) {
this.log(text, "cyan");
};
ConsoleLogger.prototype.white = function (text) {
this.log(text, "white");
};
ConsoleLogger.prototype.logBg = function (text, font, bg) {
if (font === void 0) { font = "white"; }
if (bg === void 0) { bg = "black"; }
if (this.debug) {
console.log("%c ".concat(text), "color: ".concat(font, "; background-color: ").concat(bg));
}
};
ConsoleLogger.prototype.errorBg = function (text) {
this.logBg(text, "white", "red");
};
ConsoleLogger.prototype.successBg = function (text) {
this.logBg(text, "white", "green");
};
ConsoleLogger.prototype.warningBg = function (text) {
this.logBg(text, "red", "yellow");
};
ConsoleLogger.prototype.redBg = function (text) {
this.logBg(text, "white", "red");
};
ConsoleLogger.prototype.greenBg = function (text) {
this.logBg(text, "white", "green");
};
ConsoleLogger.prototype.yellowBg = function (text) {
this.logBg(text, "red", "yellow");
};
ConsoleLogger.prototype.blueBg = function (text) {
this.logBg(text, "white", "blue");
};
ConsoleLogger.prototype.magentaBg = function (text) {
this.logBg(text, "white", "magenta");
};
ConsoleLogger.prototype.cyanBg = function (text) {
this.logBg(text, "white", "cyan");
};
ConsoleLogger.prototype.whiteBg = function (text) {
this.logBg(text, "black", "white");
};
return ConsoleLogger;
}());
exports.ConsoleLogger = ConsoleLogger;
;