* Write detailed error log to .codegraph/errors.log
(projectPath: string, errors: Array<{ message: string; filePath?: string; severity: string; code?: string }>)
| 610 | * Write detailed error log to .codegraph/errors.log |
| 611 | */ |
| 612 | function writeErrorLog(projectPath: string, errors: Array<{ message: string; filePath?: string; severity: string; code?: string }>): void { |
| 613 | const cgDir = getCodeGraphDir(projectPath); |
| 614 | if (!fs.existsSync(cgDir)) return; |
| 615 | |
| 616 | const logPath = path.join(cgDir, 'errors.log'); |
| 617 | |
| 618 | // Group errors by file path |
| 619 | const errorsByFile = new Map<string, Array<{ message: string; code?: string }>>(); |
| 620 | const noFileErrors: Array<{ message: string; code?: string }> = []; |
| 621 | |
| 622 | for (const err of errors) { |
| 623 | if (err.severity !== 'error') continue; |
| 624 | if (err.filePath) { |
| 625 | let list = errorsByFile.get(err.filePath); |
| 626 | if (!list) { |
| 627 | list = []; |
| 628 | errorsByFile.set(err.filePath, list); |
| 629 | } |
| 630 | list.push({ message: err.message, code: err.code }); |
| 631 | } else { |
| 632 | noFileErrors.push({ message: err.message, code: err.code }); |
| 633 | } |
| 634 | } |
| 635 | |
| 636 | const lines: string[] = [ |
| 637 | `CodeGraph Error Log - ${new Date().toISOString()}`, |
| 638 | `${errorsByFile.size} files with errors`, |
| 639 | '', |
| 640 | ]; |
| 641 | |
| 642 | for (const [filePath, fileErrors] of errorsByFile) { |
| 643 | for (const err of fileErrors) { |
| 644 | lines.push(`${filePath}: ${err.message}`); |
| 645 | } |
| 646 | } |
| 647 | |
| 648 | for (const err of noFileErrors) { |
| 649 | lines.push(err.message); |
| 650 | } |
| 651 | |
| 652 | fs.writeFileSync(logPath, lines.join('\n') + '\n'); |
| 653 | } |
| 654 | |
| 655 | /** |
| 656 | * Telemetry for a completed full index (see TELEMETRY.md). The bounded flush |
no test coverage detected