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

Function writeErrorLog

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

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