sourcecontrol
Version:
A modern TypeScript CLI application for source control
65 lines • 1.79 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.logger = void 0;
const chalk_1 = __importDefault(require("chalk"));
class Logger {
constructor() {
this._level = 'info';
}
set level(level) {
this._level = level;
}
get level() {
return this._level;
}
shouldLog(level) {
const levels = {
debug: 0,
info: 1,
warn: 2,
error: 3,
silent: 4,
};
return levels[level] >= levels[this._level];
}
debug(message, ...args) {
if (this.shouldLog('debug')) {
console.log(chalk_1.default.gray(`[DEBUG] ${message}`), ...args);
}
}
info(message, ...args) {
if (this.shouldLog('info')) {
console.log(chalk_1.default.blue(`[INFO] ${message}`), ...args);
}
}
success(message, ...args) {
if (this.shouldLog('info')) {
console.log(chalk_1.default.green(`✓ ${message}`), ...args);
}
}
warn(message, ...args) {
if (this.shouldLog('warn')) {
console.warn(chalk_1.default.yellow(`⚠ ${message}`), ...args);
}
}
error(message, ...args) {
if (this.shouldLog('error')) {
console.error(chalk_1.default.red(`✗ ${message}`), ...args);
}
}
log(message, ...args) {
if (this.shouldLog('info')) {
console.log(message, ...args);
}
}
newLine() {
if (this.shouldLog('info')) {
console.log();
}
}
}
exports.logger = new Logger();
//# sourceMappingURL=logger.js.map
;