MCPcopy
hub / github.com/colbymchenry/codegraph / writeErrorLog

Function writeErrorLog

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

402 * Write detailed error log to .codegraph/errors.log
403 */
404function writeErrorLog(projectPath: string, errors: Array<{ message: string; filePath?: string; severity: string; code?: string }>): void {
405 const cgDir = getCodeGraphDir(projectPath);
406 if (!fs.existsSync(cgDir)) return;
407
408 const logPath = path.join(cgDir, 'errors.log');
409
410 // Group errors by file path
411 const errorsByFile = new Map<string, Array<{ message: string; code?: string }>>();
412 const noFileErrors: Array<{ message: string; code?: string }> = [];
413
414 for (const err of errors) {
415 if (err.severity !== 'error') continue;
416 if (err.filePath) {
417 let list = errorsByFile.get(err.filePath);
418 if (!list) {
419 list = [];
420 errorsByFile.set(err.filePath, list);
421 }
422 list.push({ message: err.message, code: err.code });
423 } else {
424 noFileErrors.push({ message: err.message, code: err.code });
425 }
426 }
427
428 const lines: string[] = [
429 `CodeGraph Error Log - ${new Date().toISOString()}`,
430 `${errorsByFile.size} files with errors`,
431 '',
432 ];
433
434 for (const [filePath, fileErrors] of errorsByFile) {
435 for (const err of fileErrors) {
436 lines.push(`${filePath}: ${err.message}`);
437 }
438 }
439
440 for (const err of noFileErrors) {
441 lines.push(err.message);
442 }
443
444 fs.writeFileSync(logPath, lines.join('\n') + '\n');
445}
446
447/**
448 * Telemetry for a completed full index (see TELEMETRY.md). The bounded flush

Callers 1

printIndexResultFunction · 0.85

Calls 4

getCodeGraphDirFunction · 0.90
joinMethod · 0.80
setMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected