@foxpage/foxpage-component-shared
Version:
foxpage component shared
46 lines (45 loc) • 1.74 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.logger = exports.Logger = void 0;
const chalk_1 = __importDefault(require("chalk"));
const util_1 = require("util");
const debug_1 = __importDefault(require("debug"));
const log_symbols_1 = __importDefault(require("log-symbols"));
const debug = (0, debug_1.default)('foxpage');
function prefix(level) {
return `${level}: `;
}
class Logger {
error(msg, ...args) {
const f = prefix('Error') + (0, util_1.format)(msg, ...args);
console.error(log_symbols_1.default.error, chalk_1.default.red(f));
}
warn(msg, ...args) {
const f = prefix('Warn') + (0, util_1.format)(msg, ...args);
console.warn(log_symbols_1.default.warning, chalk_1.default.yellow(f));
}
info(msg, ...args) {
const f = prefix('Info') + (0, util_1.format)(msg, ...args);
console.log(log_symbols_1.default.info, chalk_1.default.blueBright(f));
}
success(msg, ...args) {
const f = prefix('Success') + (0, util_1.format)(msg, ...args);
console.log(log_symbols_1.default.success, chalk_1.default.blueBright(f));
}
debug(msg, ...args) {
const m = (0, util_1.format)(msg, ...args);
debug(m);
}
colorLog(color, msg, ...args) {
const f = prefix('Log') + (0, util_1.format)(msg, ...args);
console.log(chalk_1.default[color](f));
}
colorMsg(color, msg, ...args) {
const f = (0, util_1.format)(msg, ...args);
console.log(chalk_1.default[color](f));
}
}
exports.Logger = Logger;
exports.logger = new Logger();