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

Function writeErrorLog

src/bin/codegraph.ts:646–687  ·  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

644 * Write detailed error log to .codegraph/errors.log
645 */
646function writeErrorLog(projectPath: string, errors: Array<{ message: string; filePath?: string; severity: string; code?: string }>): void {
647 const cgDir = getCodeGraphDir(projectPath);
648 if (!fs.existsSync(cgDir)) return;
649
650 const logPath = path.join(cgDir, 'errors.log');
651
652 // Group errors by file path
653 const errorsByFile = new Map<string, Array<{ message: string; code?: string }>>();
654 const noFileErrors: Array<{ message: string; code?: string }> = [];
655
656 for (const err of errors) {
657 if (err.severity !== 'error') continue;
658 if (err.filePath) {
659 let list = errorsByFile.get(err.filePath);
660 if (!list) {
661 list = [];
662 errorsByFile.set(err.filePath, list);
663 }
664 list.push({ message: err.message, code: err.code });
665 } else {
666 noFileErrors.push({ message: err.message, code: err.code });
667 }
668 }
669
670 const lines: string[] = [
671 `CodeGraph Error Log - ${new Date().toISOString()}`,
672 `${errorsByFile.size} files with errors`,
673 '',
674 ];
675
676 for (const [filePath, fileErrors] of errorsByFile) {
677 for (const err of fileErrors) {
678 lines.push(`${filePath}: ${err.message}`);
679 }
680 }
681
682 for (const err of noFileErrors) {
683 lines.push(err.message);
684 }
685
686 fs.writeFileSync(logPath, lines.join('\n') + '\n');
687}
688
689/**
690 * 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