MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / writeErrorLog

Function writeErrorLog

src/bin/codegraph.ts:612–653  ·  view source on GitHub ↗

* Write detailed error log to .codegraph/errors.log

(projectPath: string, errors: Array<{ message: string; filePath?: string; severity: string; code?: string }>)

Source from the content-addressed store, hash-verified

610 * Write detailed error log to .codegraph/errors.log
611 */
612function 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

Callers 1

printIndexResultFunction · 0.85

Calls 5

getCodeGraphDirFunction · 0.90
pushMethod · 0.80
getMethod · 0.65
joinMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected