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

Function writeErrorLog

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

547 * Write detailed error log to .codegraph/errors.log
548 */
549function writeErrorLog(projectPath: string, errors: Array<{ message: string; filePath?: string; severity: string; code?: string }>): void {
550 const cgDir = getCodeGraphDir(projectPath);
551 if (!fs.existsSync(cgDir)) return;
552
553 const logPath = path.join(cgDir, 'errors.log');
554
555 // Group errors by file path
556 const errorsByFile = new Map<string, Array<{ message: string; code?: string }>>();
557 const noFileErrors: Array<{ message: string; code?: string }> = [];
558
559 for (const err of errors) {
560 if (err.severity !== 'error') continue;
561 if (err.filePath) {
562 let list = errorsByFile.get(err.filePath);
563 if (!list) {
564 list = [];
565 errorsByFile.set(err.filePath, list);
566 }
567 list.push({ message: err.message, code: err.code });
568 } else {
569 noFileErrors.push({ message: err.message, code: err.code });
570 }
571 }
572
573 const lines: string[] = [
574 `CodeGraph Error Log - ${new Date().toISOString()}`,
575 `${errorsByFile.size} files with errors`,
576 '',
577 ];
578
579 for (const [filePath, fileErrors] of errorsByFile) {
580 for (const err of fileErrors) {
581 lines.push(`${filePath}: ${err.message}`);
582 }
583 }
584
585 for (const err of noFileErrors) {
586 lines.push(err.message);
587 }
588
589 fs.writeFileSync(logPath, lines.join('\n') + '\n');
590}
591
592/**
593 * Telemetry for a completed full index (see TELEMETRY.md). The bounded flush

Callers 1

printIndexResultFunction · 0.85

Calls 4

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

Tested by

no test coverage detected