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