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

Function writeErrorLog

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

663 * Write detailed error log to .codegraph/errors.log
664 */
665function writeErrorLog(projectPath: string, errors: Array<{ message: string; filePath?: string; severity: string; code?: string }>): void {
666 const cgDir = getCodeGraphDir(projectPath);
667 if (!fs.existsSync(cgDir)) return;
668
669 const logPath = path.join(cgDir, 'errors.log');
670
671 // Group errors by file path
672 const errorsByFile = new Map<string, Array<{ message: string; code?: string }>>();
673 const noFileErrors: Array<{ message: string; code?: string }> = [];
674
675 for (const err of errors) {
676 if (err.severity !== 'error') continue;
677 if (err.filePath) {
678 let list = errorsByFile.get(err.filePath);
679 if (!list) {
680 list = [];
681 errorsByFile.set(err.filePath, list);
682 }
683 list.push({ message: err.message, code: err.code });
684 } else {
685 noFileErrors.push({ message: err.message, code: err.code });
686 }
687 }
688
689 const lines: string[] = [
690 `CodeGraph Error Log - ${new Date().toISOString()}`,
691 `${errorsByFile.size} files with errors`,
692 '',
693 ];
694
695 for (const [filePath, fileErrors] of errorsByFile) {
696 for (const err of fileErrors) {
697 lines.push(`${filePath}: ${err.message}`);
698 }
699 }
700
701 for (const err of noFileErrors) {
702 lines.push(err.message);
703 }
704
705 fs.writeFileSync(logPath, lines.join('\n') + '\n');
706}
707
708/**
709 * 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