* Write detailed error log to .codegraph/errors.log
(projectPath: string, errors: Array<{ message: string; filePath?: string; severity: string; code?: string }>)
| 673 | * Write detailed error log to .codegraph/errors.log |
| 674 | */ |
| 675 | function writeErrorLog(projectPath: string, errors: Array<{ message: string; filePath?: string; severity: string; code?: string }>): void { |
| 676 | const cgDir = getCodeGraphDir(projectPath); |
| 677 | if (!fs.existsSync(cgDir)) return; |
| 678 | |
| 679 | const logPath = path.join(cgDir, 'errors.log'); |
| 680 | |
| 681 | // Group errors by file path |
| 682 | const errorsByFile = new Map<string, Array<{ message: string; code?: string }>>(); |
| 683 | const noFileErrors: Array<{ message: string; code?: string }> = []; |
| 684 | |
| 685 | for (const err of errors) { |
| 686 | if (err.severity !== 'error') continue; |
| 687 | if (err.filePath) { |
| 688 | let list = errorsByFile.get(err.filePath); |
| 689 | if (!list) { |
| 690 | list = []; |
| 691 | errorsByFile.set(err.filePath, list); |
| 692 | } |
| 693 | list.push({ message: err.message, code: err.code }); |
| 694 | } else { |
| 695 | noFileErrors.push({ message: err.message, code: err.code }); |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | const lines: string[] = [ |
| 700 | `CodeGraph Error Log - ${new Date().toISOString()}`, |
| 701 | `${errorsByFile.size} files with errors`, |
| 702 | '', |
| 703 | ]; |
| 704 | |
| 705 | for (const [filePath, fileErrors] of errorsByFile) { |
| 706 | for (const err of fileErrors) { |
| 707 | lines.push(`${filePath}: ${err.message}`); |
| 708 | } |
| 709 | } |
| 710 | |
| 711 | for (const err of noFileErrors) { |
| 712 | lines.push(err.message); |
| 713 | } |
| 714 | |
| 715 | fs.writeFileSync(logPath, lines.join('\n') + '\n'); |
| 716 | } |
| 717 | |
| 718 | /** |
| 719 | * Telemetry for a completed full index (see TELEMETRY.md). The bounded flush |
no test coverage detected