UNPKG

git-contribution-stats

Version:

High-performance library to generate GitHub contribution reports with timeout controls, circuit breakers, and selective processing for AWS Lambda and background jobs

157 lines (156 loc) 4.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Logger = void 0; const signale_1 = require("signale"); class Logger { constructor(config) { this.config = { level: 'info', scope: [], disabled: false, interactive: false, timers: true }; this.logLevels = { debug: 0, info: 1, warn: 2, error: 3 }; this.config = { ...this.config, ...config }; const options = { scope: this.config.scope.join(', '), disabled: this.config.disabled, interactive: this.config.interactive, // timers property removed as it is not compatible types: { success: { badge: '', color: 'green', label: 'success' }, log: { badge: '', color: 'blue', label: 'log' }, debug: { badge: '', color: 'magenta', label: 'debug' }, info: { badge: '', color: 'cyan', label: 'info' }, warn: { badge: '', color: 'yellow', label: 'warn' }, error: { badge: '', color: 'red', label: 'error' }, pending: { badge: '', color: 'blue', label: 'pending' }, complete: { badge: '', color: 'green', label: 'complete' }, start: { badge: '', color: 'magenta', label: 'start' }, pause: { badge: '', color: 'yellow', label: 'pause' }, note: { badge: '', color: 'blue', label: 'note' }, time: { badge: '', color: 'blue', label: 'time' }, timeEnd: { badge: '', color: 'blue', label: 'timeEnd' }, group: { badge: '', color: 'blue', label: 'group' }, } }; this.logger = new signale_1.Signale({ ...options }); } debug(message, ...args) { if (this.logLevels['debug'] >= this.logLevels[this.config.level]) { this.logger.debug(message, ...args); } } info(message, ...args) { if (this.logLevels['info'] >= this.logLevels[this.config.level]) { this.logger.info(message, ...args); } } warn(message, ...args) { if (this.logLevels['warn'] >= this.logLevels[this.config.level]) { this.logger.warn(message, ...args); } } error(message, ...args) { if (this.logLevels['error'] >= this.logLevels[this.config.level]) { this.logger.error(message, ...args); } } success(message, ...args) { this.logger.success(message, ...args); } pending(message, ...args) { this.logger.pending(message, ...args); } complete(message, ...args) { this.logger.complete(message, ...args); } start(message, ...args) { this.logger.start(message, ...args); } pause(message, ...args) { this.logger.pause(message, ...args); } note(message, ...args) { this.logger.note(message, ...args); } time(label) { if (this.config.timers) { this.logger.time(console.time(label)); } } timeEnd(label) { if (this.config.timers) { this.logger.timeEnd(label); } } group(label) { this.logger.group(label); } groupEnd() { this.logger.groupEnd(); } } exports.Logger = Logger;