solidworks-mcp-server
Version:
Clean Architecture SolidWorks MCP Server - Production-ready with SOLID principles
65 lines • 2.23 kB
JavaScript
/**
* Logger Implementation
* Production-ready logging with multiple transports
*/
import winston from 'winston';
export class Logger {
winston;
constructor(config = {}) {
const transports = [];
// Console transport
if (config.console !== false) {
transports.push(new winston.transports.Console({
format: winston.format.combine(winston.format.colorize(), winston.format.timestamp(), winston.format.printf(({ timestamp, level, message, ...meta }) => {
const metaStr = Object.keys(meta).length ? JSON.stringify(meta, null, 2) : '';
return `${timestamp} [${level}]: ${message} ${metaStr}`;
}))
}));
}
// File transport
if (config.file && config.filePath) {
transports.push(new winston.transports.File({
filename: config.filePath,
format: winston.format.json(),
maxsize: config.maxFileSize || 10485760, // 10MB
maxFiles: config.maxFiles || 5
}));
}
this.winston = winston.createLogger({
level: config.level || 'info',
format: winston.format.combine(winston.format.timestamp(), winston.format.errors({ stack: true }), winston.format.json()),
transports
});
}
debug(message, context) {
this.winston.debug(message, context);
}
info(message, context) {
this.winston.info(message, context);
}
warn(message, context) {
this.winston.warn(message, context);
}
error(message, error, context) {
this.winston.error(message, {
...context,
error: error ? {
message: error.message,
stack: error.stack,
name: error.name
} : undefined
});
}
fatal(message, error, context) {
this.winston.error(message, {
...context,
level: 'fatal',
error: error ? {
message: error.message,
stack: error.stack,
name: error.name
} : undefined
});
}
}
//# sourceMappingURL=logger.js.map