* Write detailed error log to .codegraph/errors.log
(projectPath: string, errors: Array<{ message: string; filePath?: string; severity: string; code?: string }>)
| 530 | * Write detailed error log to .codegraph/errors.log |
| 531 | */ |
| 532 | function writeErrorLog(projectPath: string, errors: Array<{ message: string; filePath?: string; severity: string; code?: string }>): void { |
| 533 | const cgDir = getCodeGraphDir(projectPath); |
| 534 | if (!fs.existsSync(cgDir)) return; |
| 535 | |
| 536 | const logPath = path.join(cgDir, 'errors.log'); |
| 537 | |
| 538 | // Group errors by file path |
| 539 | const errorsByFile = new Map<string, Array<{ message: string; code?: string }>>(); |
| 540 | const noFileErrors: Array<{ message: string; code?: string }> = []; |
| 541 | |
| 542 | for (const err of errors) { |
| 543 | if (err.severity !== 'error') continue; |
| 544 | if (err.filePath) { |
| 545 | let list = errorsByFile.get(err.filePath); |
| 546 | if (!list) { |
| 547 | list = []; |
| 548 | errorsByFile.set(err.filePath, list); |
| 549 | } |
| 550 | list.push({ message: err.message, code: err.code }); |
| 551 | } else { |
| 552 | noFileErrors.push({ message: err.message, code: err.code }); |
| 553 | } |
| 554 | } |
| 555 | |
| 556 | const lines: string[] = [ |
| 557 | `CodeGraph Error Log - ${new Date().toISOString()}`, |
| 558 | `${errorsByFile.size} files with errors`, |
| 559 | '', |
| 560 | ]; |
| 561 | |
| 562 | for (const [filePath, fileErrors] of errorsByFile) { |
| 563 | for (const err of fileErrors) { |
| 564 | lines.push(`${filePath}: ${err.message}`); |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | for (const err of noFileErrors) { |
| 569 | lines.push(err.message); |
| 570 | } |
| 571 | |
| 572 | fs.writeFileSync(logPath, lines.join('\n') + '\n'); |
| 573 | } |
| 574 | |
| 575 | /** |
| 576 | * Telemetry for a completed full index (see TELEMETRY.md). The bounded flush |
no test coverage detected