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

Function writeErrorLog

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

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