UNPKG

rjweb-server

Version:

Easy and Robust Way to create a Web Server with Many Easy-to-use Features in NodeJS

82 lines (81 loc) 2.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.colors = void 0; exports.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' } }; /** * A Logger used for automatically parsing messages from any place * @example * ``` * const logger = new Logger(...) * ``` * @since 7.4.0 */ 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(`${exports.colors.bg.red} ERROR ${exports.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(`${exports.colors.bg.yellow} WARN ${exports.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(`${exports.colors.bg.blue} DEBUG ${exports.colors.reset}`, ...messages); this.logs++; return this; } } exports.default = Logger;