mlld
Version:
mlld: a modular prompt scripting language
1 lines • 17.7 kB
Source Map (JSON)
{"version":3,"sources":["../core/config/logging.ts","../core/utils/logger.ts"],"names":["loggingConfig","levels","config","npm","colors","files","directory","mainLog","errorLog","maxSize","maxFiles","tailable","defaultLevel","format","timestamp","includeTimestamp","colorize","services","state","level","includeMetadata","parser","interpreter","filesystem","validation","output","path","directive","circularity","resolution","import","cli","embed","winston","addColors","consoleFormat","combine","all","printf","message","service","metadata","process","env","MLLD_DEBUG","includes","msg","Object","keys","length","JSON","stringify","fileFormat","json","getLogLevel","LOG_LEVEL","NODE_ENV","TEST_LOG_LEVEL","LoggerFactory","createServiceLogger","serviceName","serviceConfig","getServiceLogLevel","logger","createLogger","defaultMeta","transports","Console","currentLevel","defineProperty","get","set","newLevel","forEach","transport","loggerFactory","fs","existsSync","File","filename","join","maxsize","mkdirSync","error","stateLogger","parserLogger","interpreterLogger","filesystemLogger","outputLogger","pathLogger","directiveLogger","cliLogger","fileTransport","add"],"mappings":";;;;;AAEO,IAAMA,aAAgB,GAAA;;AAE3BC,EAAAA,MAAAA,EAAQC,OAAOC,GAAIF,CAAAA,MAAAA;;AAGnBG,EAAAA,MAAAA,EAAQF,OAAOC,GAAIC,CAAAA,MAAAA;;EAGnBC,KAAO,EAAA;IACLC,SAAW,EAAA,MAAA;IACXC,OAAS,EAAA,UAAA;IACTC,QAAU,EAAA,WAAA;IACVC,OAAS,EAAA,OAAA;IACTC,QAAU,EAAA,CAAA;IACVC,QAAU,EAAA;AACZ,GAAA;;EAGAC,YAAc,EAAA,OAAA;;EAGdC,MAAQ,EAAA;IACNC,SAAW,EAAA,qBAAA;IACXC,gBAAkB,EAAA,IAAA;IAClBC,QAAU,EAAA;AACZ,GAAA;;EAGAC,QAAU,EAAA;IACRC,KAAO,EAAA;MACLC,KAAO,EAAA,OAAA;MACPC,eAAiB,EAAA;AACnB,KAAA;IACAC,MAAQ,EAAA;MACNF,KAAO,EAAA,OAAA;MACPC,eAAiB,EAAA;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;AAC5C,GAAA,CAAA,OAAS6E,KAAO,EAAA;AAGhB;AACF;AAUO,IAAMC,WAAAA,GAAczB,oBAAoB,OAAA,CAAA;AACxC,IAAM0B,YAAAA,GAAe1B,oBAAoB,QAAA,CAAA;AACnC2B,IAAAA,iBAAAA,GAAoB3B,oBAAoB,aAAA;AAC9C,IAAM4B,gBAAAA,GAAmB5B,oBAAoB,YAAA,CAAA;AACpBA,oBAAoB,YAAA;AAC7C,IAAM6B,YAAAA,GAAe7B,oBAAoB,QAAA,CAAA;AACzC,IAAM8B,UAAAA,GAAa9B,oBAAoB,MAAA,CAAA;AACvC,IAAM+B,eAAAA,GAAkB/B,oBAAoB,WAAA,CAAA;AAClBA,oBAAoB,aAAA;AACrBA,oBAAoB,YAAA;AACxBA,oBAAoB,QAAA;AACzC,IAAMgC,SAAAA,GAAYhC,oBAAoB,KAAA,CAAA;AAClBA,oBAAoB,OAAA;AAM/C,IAAIjB,QAAQC,GAAIa,CAAAA,QAAAA,KAAa,gBAAgBoB,EAAGC,CAAAA,UAAAA,CAAW,MAAA,CAAS,EAAA;AAClE,EAAA,MAAMe,aAAgB,GAAA,IAAI3D,OAAQiC,CAAAA,UAAAA,CAAWY,IAAK,CAAA;IAChDC,QAAU,EAAA,gBAAA;IACV5D,KAAO,EAAA;GACT,CAAA;AAGA,EAAA;AACEwE,IAAAA,SAAAA;AACAD,IAAAA,eAAAA;AACAJ,IAAAA,iBAAAA;AACAD,IAAAA,YAAAA;AACAG,IAAAA,YAAAA;AACAD,IAAAA,gBAAAA;AACAE,IAAAA,UAAAA;AACAL,IAAAA;AACAX,GAAAA,CAAAA,OAAAA,CAAQV,CAAAA,OAAAA,KAAAA;AACRA,IAAAA,OAAAA,CAAO8B,IAAID,aAAAA,CAAAA;GACb,CAAA;AACF","file":"chunk-XGMRAGIT.mjs","sourcesContent":["import { config } from 'winston';\n\nexport const loggingConfig = {\n // Log levels in order of increasing verbosity\n levels: config.npm.levels,\n\n // Color scheme for different log levels\n colors: config.npm.colors,\n\n // File configuration\n files: {\n directory: 'logs',\n mainLog: 'mlld.log',\n errorLog: 'error.log',\n maxSize: 5242880, // 5MB\n maxFiles: 5,\n tailable: true\n },\n\n // Default level based on environment\n defaultLevel: 'error',\n\n // Format configuration\n format: {\n timestamp: 'YYYY-MM-DD HH:mm:ss',\n includeTimestamp: true,\n colorize: true\n },\n\n // Service-specific settings\n services: {\n state: {\n level: 'error',\n includeMetadata: true\n },\n parser: {\n level: 'error',\n includeMetadata: true\n },\n interpreter: {\n level: 'error',\n includeMetadata: true\n },\n filesystem: {\n level: 'error',\n includeMetadata: true\n },\n validation: {\n level: 'error',\n includeMetadata: true\n },\n output: {\n level: 'error',\n includeMetadata: true\n },\n path: {\n level: 'error',\n includeMetadata: true\n },\n directive: {\n level: 'error',\n includeMetadata: true\n },\n circularity: {\n level: 'error',\n includeMetadata: true\n },\n resolution: {\n level: 'error',\n includeMetadata: true\n },\n import: {\n level: 'error',\n includeMetadata: true\n },\n cli: {\n level: 'error'\n },\n embed: {\n level: 'error',\n includeMetadata: true\n }\n }\n} as const; ","import winston from 'winston';\nimport path from 'path';\nimport { loggingConfig } from '@core/config/logging';\n// Removed tsyringe imports - no longer using dependency injection\nimport fs from 'fs';\n\n/**\n * Interface for the standard Logger to enable DI resolution\n */\nexport interface ILogger {\n error(message: string, context?: Record<string, unknown>): void;\n warn(message: string, context?: Record<string, unknown>): void;\n info(message: string, context?: Record<string, unknown>): void;\n debug(message: string, context?: Record<string, unknown>): void;\n trace(message: string, context?: Record<string, unknown>): void;\n level: string;\n}\n\n/**\n * Interface for the LoggerFactory to enable DI resolution\n */\nexport interface ILoggerFactory {\n createServiceLogger(serviceName: keyof typeof loggingConfig.services): winston.Logger;\n}\n\n// Add colors to Winston\nwinston.addColors(loggingConfig.colors);\n\n// Create formatters\nconst consoleFormat = winston.format.combine(\n winston.format.timestamp({ format: loggingConfig.format.timestamp }),\n winston.format.colorize({ all: loggingConfig.format.colorize }),\n winston.format.printf(({ level, message, timestamp, service, ...metadata }) => {\n // In non-debug mode, use more concise output\n if (process.env.MLLD_DEBUG !== 'true') {\n // Only show error messages, no debug/info/etc\n if (!level.includes('error')) {\n return '';\n }\n // For errors, include minimal context\n return `Error: ${message}`;\n }\n \n // Full verbose output for debug mode\n let msg = `${timestamp} [${level}]${service ? ` [${service}]` : ''} ${message}`;\n if (Object.keys(metadata).length > 0) {\n msg += '\\n' + JSON.stringify(metadata, null, 2);\n }\n return msg;\n })\n);\n\nconst fileFormat = winston.format.combine(\n winston.format.timestamp({ format: loggingConfig.format.timestamp }),\n winston.format.json()\n);\n\n// Determine the log level based on environment variables\nconst getLogLevel = () => {\n // Explicit LOG_LEVEL takes precedence\n if (process.env.LOG_LEVEL) {\n return process.env.LOG_LEVEL;\n }\n \n // During tests, respect TEST_LOG_LEVEL or default to silent for minimal output\n if (process.env.NODE_ENV === 'test') {\n return process.env.TEST_LOG_LEVEL || 'error';\n }\n \n // In debug mode use debug level\n if (process.env.MLLD_DEBUG === 'true') {\n return 'debug';\n }\n \n // Otherwise use the default level\n return loggingConfig.defaultLevel;\n};\n\n/**\n * Factory service for creating Winston loggers\n */\nexport class LoggerFactory implements ILoggerFactory {\n /**\n * Create a service-specific logger\n * @param serviceName The name of the service to create a logger for\n * @returns A Winston logger configured for the specified service\n */\n createServiceLogger(serviceName: keyof typeof loggingConfig.services): winston.Logger {\n const serviceConfig = loggingConfig.services[serviceName];\n \n // Determine the service-specific log level based on environment variables\n const getServiceLogLevel = () => {\n // Explicit LOG_LEVEL takes precedence\n if (process.env.LOG_LEVEL) {\n return process.env.LOG_LEVEL;\n }\n \n // During tests, respect TEST_LOG_LEVEL or default to error for minimal output\n if (process.env.NODE_ENV === 'test') {\n return process.env.TEST_LOG_LEVEL || 'error';\n }\n \n // In debug mode use debug level\n if (process.env.MLLD_DEBUG === 'true') {\n return 'debug';\n }\n \n // Otherwise use the service's configured level\n return serviceConfig.level;\n };\n \n const logger = winston.createLogger({\n level: getServiceLogLevel(),\n format: winston.format.combine(\n winston.format.timestamp(),\n winston.format.json()\n ),\n defaultMeta: { service: serviceName },\n transports: [\n // Only use console transport outside of tests\n ...(process.env.NODE_ENV === 'test' ? [] : [\n new winston.transports.Console({\n format: consoleFormat,\n level: getServiceLogLevel()\n })\n ])\n ]\n });\n\n // Add a method to update the log level\n let currentLevel = serviceConfig.level;\n Object.defineProperty(logger, 'level', {\n get() {\n return currentLevel;\n },\n set(newLevel: string) {\n currentLevel = newLevel;\n logger.transports.forEach(transport => {\n transport.level = newLevel;\n });\n }\n });\n\n return logger;\n }\n}\n\n// Singleton instance for backward compatibility\nexport const loggerFactory = new LoggerFactory();\n\n// Create the logger instance\nexport const logger = winston.createLogger({\n level: getLogLevel(),\n levels: loggingConfig.levels,\n transports: [\n // Console transport (but not during silent test)\n ...((process.env.NODE_ENV === 'test' && !process.env.TEST_LOG_LEVEL) ? [] : [\n new winston.transports.Console({\n format: consoleFormat\n })\n ]),\n // File transports only if logs directory exists (not in serverless)\n ...(fs.existsSync(loggingConfig.files.directory) ? [\n // File transport for all logs\n new winston.transports.File({\n filename: path.join(loggingConfig.files.directory, loggingConfig.files.mainLog),\n format: fileFormat,\n maxsize: loggingConfig.files.maxSize,\n maxFiles: loggingConfig.files.maxFiles,\n tailable: loggingConfig.files.tailable\n }),\n // Separate file for errors\n new winston.transports.File({\n filename: path.join(loggingConfig.files.directory, loggingConfig.files.errorLog),\n level: 'error',\n format: fileFormat,\n maxsize: loggingConfig.files.maxSize,\n maxFiles: loggingConfig.files.maxFiles,\n tailable: loggingConfig.files.tailable\n })\n ] : [])\n ]\n});\n\n// Backward compatibility function for creating service loggers\nexport function createServiceLogger(serviceName: keyof typeof loggingConfig.services): winston.Logger {\n return loggerFactory.createServiceLogger(serviceName);\n}\n\n// Ensure logs directory exists (skip in serverless environments)\nif (!fs.existsSync(loggingConfig.files.directory)) {\n try {\n fs.mkdirSync(loggingConfig.files.directory);\n } catch (error) {\n // Ignore error in serverless/read-only environments\n // File logging will be disabled\n }\n}\n\n// Add a stream interface for use with other logging tools\nexport const logStream = {\n write: (message: string): void => {\n logger.info(message.trim());\n }\n};\n\n// Create service loggers\nexport const stateLogger = createServiceLogger('state');\nexport const parserLogger = createServiceLogger('parser');\nexport const interpreterLogger = createServiceLogger('interpreter');\nexport const filesystemLogger = createServiceLogger('filesystem');\nexport const validationLogger = createServiceLogger('validation');\nexport const outputLogger = createServiceLogger('output');\nexport const pathLogger = createServiceLogger('path');\nexport const directiveLogger = createServiceLogger('directive');\nexport const circularityLogger = createServiceLogger('circularity');\nexport const resolutionLogger = createServiceLogger('resolution');\nexport const importLogger = createServiceLogger('import');\nexport const cliLogger = createServiceLogger('cli');\nexport const embedLogger = createServiceLogger('embed');\n\n// Export default logger for general use\nexport default logger;\n\n// Add file transport in production (only if logs directory exists)\nif (process.env.NODE_ENV === 'production' && fs.existsSync('logs')) {\n const fileTransport = new winston.transports.File({\n filename: 'logs/error.log',\n level: 'error'\n });\n\n // Add to all loggers\n [\n cliLogger,\n directiveLogger,\n interpreterLogger,\n parserLogger,\n outputLogger,\n filesystemLogger,\n pathLogger,\n stateLogger\n ].forEach(logger => {\n logger.add(fileTransport);\n });\n} "]}