UNPKG

empacy

Version:

Multi-Agent MCP Server - Enables multiple AI agents to collaborate on complex development projects through hierarchical organization

65 lines (57 loc) 1.67 kB
import winston from 'winston'; /** * Winston logger configuration for Empacy * Provides structured logging with different levels and formats */ const logger = winston.createLogger({ level: process.env.LOG_LEVEL || 'info', format: winston.format.combine( winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss', }), winston.format.errors({ stack: true }), winston.format.json() ), defaultMeta: { service: 'empacy' }, transports: [ // Console transport for development new winston.transports.Console({ format: winston.format.combine( winston.format.colorize(), winston.format.simple(), winston.format.printf(({ timestamp, level, message, service, ...meta }) => { let metaStr = ''; if (Object.keys(meta).length > 0) { metaStr = ` ${JSON.stringify(meta)}`; } return `${timestamp} [${service}] ${level}: ${message}${metaStr}`; }) ), }), // File transport for production logging new winston.transports.File({ filename: 'logs/error.log', level: 'error', maxsize: 5242880, // 5MB maxFiles: 5, }), new winston.transports.File({ filename: 'logs/combined.log', maxsize: 5242880, // 5MB maxFiles: 5, }), ], }); // Create logs directory if it doesn't exist import { mkdir } from 'fs/promises'; import { existsSync } from 'fs'; if (!existsSync('logs')) { mkdir('logs', { recursive: true }).catch(console.error); } // Add stream for Morgan HTTP logging logger.stream = { write: (message) => { logger.info(message.trim()); }, }; export { logger };