UNPKG

tyrion-git-mcp

Version:

Revolutionary Git MCP with Rust+WASM+TypeScript - 3x-10x performance boost vs traditional solutions

232 lines 7.2 kB
// S04 Git MCP Server - Revolutionary Logging System // Tony Stark's JARVIS-Level Intelligence Logging import winston from 'winston'; import chalk from 'chalk'; /** * Revolutionary logging system with Tony Stark's intelligence */ class RevolutionaryLogger { winston; config; constructor() { this.config = { level: 'info', format: 'cli', }; this.winston = this.createLogger(); } /** * Configure logger with new settings */ configure(config) { this.config = { ...this.config, ...config }; this.winston = this.createLogger(); } /** * Create Winston logger with revolutionary formatting */ createLogger() { const formats = [ winston.format.timestamp(), winston.format.errors({ stack: true }), ]; // Add format based on configuration if (this.config.format === 'cli') { formats.push(this.createCliFormat()); } else { formats.push(winston.format.json()); } return winston.createLogger({ level: this.config.level, format: winston.format.combine(...formats), transports: [ new winston.transports.Console({ handleExceptions: true, handleRejections: true, }), ], exitOnError: false, }); } /** * Create revolutionary CLI format with colors and emojis */ createCliFormat() { return winston.format.printf(({ level, message, timestamp, ...meta }) => { const ts = new Date(timestamp).toLocaleTimeString(); // Color and emoji mapping const levelMap = { error: { emoji: '❌', color: chalk.red }, warn: { emoji: '⚠️', color: chalk.yellow }, info: { emoji: '🔹', color: chalk.blue }, debug: { emoji: '🔍', color: chalk.gray }, verbose: { emoji: '💬', color: chalk.cyan }, }; const levelInfo = levelMap[level] || { emoji: '📝', color: chalk.white }; // Format main message let formattedMessage = `${chalk.gray(ts)} ${levelInfo.emoji} ${levelInfo.color(message)}`; // Add metadata if present if (Object.keys(meta).length > 0) { const metaString = Object.entries(meta) .map(([key, value]) => `${key}=${JSON.stringify(value)}`) .join(' '); formattedMessage += ` ${chalk.dim(metaString)}`; } return formattedMessage; }); } /** * Log error with revolutionary formatting */ error(message, ...args) { if (args.length > 0) { this.winston.error(message, { args }); } else { this.winston.error(message); } } /** * Log warning with revolutionary formatting */ warn(message, ...args) { if (args.length > 0) { this.winston.warn(message, { args }); } else { this.winston.warn(message); } } /** * Log info with revolutionary formatting */ info(message, ...args) { if (args.length > 0) { this.winston.info(message, { args }); } else { this.winston.info(message); } } /** * Log debug with revolutionary formatting */ debug(message, ...args) { if (args.length > 0) { this.winston.debug(message, { args }); } else { this.winston.debug(message); } } /** * Log verbose with revolutionary formatting */ verbose(message, ...args) { if (args.length > 0) { this.winston.verbose(message, { args }); } else { this.winston.verbose(message); } } /** * Log performance metrics with special formatting */ performance(operation, duration, success) { const emoji = success ? '⚡' : '⏱️'; const color = success ? chalk.green : chalk.yellow; const status = success ? 'SUCCESS' : 'COMPLETED'; this.winston.info(`${emoji} ${color(`PERF [${operation}]`)} ${duration.toFixed(2)}ms ${chalk.dim(status)}`); } /** * Log security events with special formatting */ security(event, severity) { const severityMap = { low: { emoji: '🔒', color: chalk.blue }, medium: { emoji: '🛡️', color: chalk.yellow }, high: { emoji: '⚠️', color: chalk.red }, critical: { emoji: '🚨', color: chalk.red }, }; const info = severityMap[severity]; this.winston.warn(`${info.emoji} ${info.color(`SECURITY [${severity.toUpperCase()}]`)} ${event}`); } /** * Log WASM bridge events with special formatting */ wasm(message, data) { const formatted = `🌉 ${chalk.magenta('WASM')} ${message}`; if (data) { this.winston.info(formatted, { wasmData: data }); } else { this.winston.info(formatted); } } /** * Log MCP protocol events with special formatting */ mcp(message, data) { const formatted = `🔗 ${chalk.cyan('MCP')} ${message}`; if (data) { this.winston.info(formatted, { mcpData: data }); } else { this.winston.info(formatted); } } /** * Log Git operations with special formatting */ git(operation, result, duration) { const emoji = result === 'success' ? '🚀' : '💥'; const color = result === 'success' ? chalk.green : chalk.red; const durationText = duration ? ` (${duration.toFixed(2)}ms)` : ''; this.winston.info(`${emoji} ${color('GIT')} ${operation}${durationText}`); } /** * Create child logger for specific component */ child(component) { return new ComponentLogger(this, component); } } /** * Component-specific logger with prefixed messages */ class ComponentLogger { parent; component; constructor(parent, component) { this.parent = parent; this.component = component; } prefix(message) { return `[${chalk.cyan(this.component)}] ${message}`; } error(message, ...args) { this.parent.error(this.prefix(message), ...args); } warn(message, ...args) { this.parent.warn(this.prefix(message), ...args); } info(message, ...args) { this.parent.info(this.prefix(message), ...args); } debug(message, ...args) { this.parent.debug(this.prefix(message), ...args); } verbose(message, ...args) { this.parent.verbose(this.prefix(message), ...args); } } // Create global logger instance export const logger = new RevolutionaryLogger(); // Export component logger factory export const createComponentLogger = (component) => { return logger.child(component); }; export { ComponentLogger }; //# sourceMappingURL=logger.js.map