MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / write_skip_logfile

Function write_skip_logfile

src/mcp/mcp.c:7402–7446  ·  view source on GitHub ↗

Write the FULL (uncapped) skip list to a per-run logfile — ONLY when >=1 file * was skipped (no logfile on a clean run). Location: * $CBM_INDEX_LOG (override) else /logs/ - .log * Returns true and fills out_path on success. */

Source from the content-addressed store, hash-verified

7400 * $CBM_INDEX_LOG (override) else <cache_dir>/logs/<project>-<epoch>.log
7401 * Returns true and fills out_path on success. */
7402static bool write_skip_logfile(const char *project, const cbm_file_error_t *errs, int count,
7403 char *out_path, size_t out_sz) {
7404 if (!errs || count <= 0) {
7405 return false;
7406 }
7407 char path[CBM_SZ_1K];
7408 const char *override = getenv("CBM_INDEX_LOG");
7409 if (override && override[0]) {
7410 snprintf(path, sizeof(path), "%s", override);
7411 } else {
7412 const char *cdir = cbm_resolve_cache_dir();
7413 if (!cdir) {
7414 return false;
7415 }
7416 char logdir[CBM_SZ_1K];
7417 snprintf(logdir, sizeof(logdir), "%s/logs", cdir);
7418 cbm_mkdir_p(logdir, 0755);
7419 snprintf(path, sizeof(path), "%s/%s-%lld.log", logdir, project ? project : "index",
7420 (long long)time(NULL));
7421 }
7422 FILE *f = cbm_fopen(path, "wb");
7423 if (!f) {
7424 cbm_log_warn("index.logfile_open_fail", "path", path);
7425 return false;
7426 }
7427 int partials = 0;
7428 for (int i = 0; i < count; i++) {
7429 if (is_parse_partial(&errs[i])) {
7430 partials++;
7431 }
7432 }
7433 (void)fprintf(f, "# codebase-memory-mcp index coverage report\n");
7434 (void)fprintf(f, "# project=%s skipped=%d parse_partial=%d\n", project ? project : "",
7435 count - partials, partials);
7436 (void)fprintf(f, "# columns: phase\treason\tpath\n");
7437 for (int i = 0; i < count; i++) {
7438 (void)fprintf(f, "%s\t%s\t%s\n", errs[i].phase ? errs[i].phase : "",
7439 errs[i].reason ? errs[i].reason : "", errs[i].path ? errs[i].path : "");
7440 }
7441 (void)fclose(f);
7442 if (out_path && out_sz) {
7443 snprintf(out_path, out_sz, "%s", path);
7444 }
7445 return true;
7446}
7447
7448/* Build the success portion of the index_repository response.
7449 * Returns true when status should be "degraded" (#334 plausibility gate). */

Callers 1

handle_index_repositoryFunction · 0.85

Calls 4

cbm_resolve_cache_dirFunction · 0.85
cbm_mkdir_pFunction · 0.85
cbm_fopenFunction · 0.85
is_parse_partialFunction · 0.85

Tested by

no test coverage detected