rjweb-server
Version:
Easy and Robust Way to create a Web Server with Many Easy-to-use Features in NodeJS
104 lines (103 loc) • 2.54 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var logger_exports = {};
__export(logger_exports, {
colors: () => colors,
default: () => Logger
});
module.exports = __toCommonJS(logger_exports);
const colors = {
reset: "\x1B[0m",
bright: "\x1B[1m",
dim: "\x1B[2m",
underscore: "\x1B[4m",
blink: "\x1B[5m",
reverse: "\x1B[7m",
hidden: "\x1B[8m",
fg: {
black: "\x1B[30m",
red: "\x1B[31m",
green: "\x1B[32m",
yellow: "\x1B[33m",
blue: "\x1B[34m",
magenta: "\x1B[35m",
cyan: "\x1B[36m",
white: "\x1B[37m",
gray: "\x1B[90m"
},
bg: {
black: "\x1B[40m",
red: "\x1B[41m",
green: "\x1B[42m",
yellow: "\x1B[43m",
blue: "\x1B[44m",
magenta: "\x1B[45m",
cyan: "\x1B[46m",
white: "\x1B[47m",
gray: "\x1B[100m",
crimson: "\x1B[48m"
}
};
class Logger {
/**
* Create a new Logger instance
* @since 7.4.0
*/
constructor(options) {
this.logs = 0;
this.options = options;
}
/**
* Log an error message
* @since 7.4.0
*/
error(...messages) {
if (!this.options.error)
return this;
console.error(`${colors.bg.red} ERROR ${colors.reset}`, ...messages);
this.logs++;
return this;
}
/**
* Log a warn message
* @since 7.4.0
*/
warn(...messages) {
if (!this.options.warn)
return this;
console.warn(`${colors.bg.yellow} WARN ${colors.reset}`, ...messages);
this.logs++;
return this;
}
/**
* Log a debug message
* @since 7.4.0
*/
debug(...messages) {
if (!this.options.debug)
return this;
console.debug(`${colors.bg.blue} DEBUG ${colors.reset}`, ...messages);
this.logs++;
return this;
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
colors
});