/**
 * Output processor that composes log format parsers and error detectors
 * Provides the main API for processing server log output
 */
/**
 * Output processor that combines log format parsing and error detection
 * This is the main class that should be used for processing server log output
 */
export class OutputProcessor {
    logFormatParser;
    errorDetector;
    constructor(logFormatParser, errorDetector) {
        this.logFormatParser = logFormatParser;
        this.errorDetector = errorDetector;
    }
    /**
     * Process log text output from the server
     * @param text Raw log text to process
     * @param isError Whether this is from stderr (error stream)
     * @returns Array of processed log entries
     */
    process(text, isError = false) {
        // First, parse the log format to extract structured information
        const parsedLines = this.logFormatParser.parse(text);
        // Then, apply error detection and create log entries
        return parsedLines.map((line) => {
            // For error output, check if it's critical
            const isCritical = isError && this.errorDetector.isCritical(line.message);
            // Build the log entry
            const entry = {
                formatted: isError ? `ERROR: ${line.formatted}` : line.formatted
            };
            // Add critical error information if applicable
            if (isCritical) {
                entry.isCritical = true;
                entry.rawMessage = line.message;
            }
            return entry;
        });
    }
    /**
     * Get the current log format parser
     */
    getLogFormatParser() {
        return this.logFormatParser;
    }
    /**
     * Get the current error detector
     */
    getErrorDetector() {
        return this.errorDetector;
    }
}
//# sourceMappingURL=output-processor.js.map