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

Function write_skip_logfile

src/mcp/mcp.c:7271–7315  ·  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

7269 * $CBM_INDEX_LOG (override) else <cache_dir>/logs/<project>-<epoch>.log
7270 * Returns true and fills out_path on success. */
7271static bool write_skip_logfile(const char *project, const cbm_file_error_t *errs, int count,
7272 char *out_path, size_t out_sz) {
7273 if (!errs || count <= 0) {
7274 return false;
7275 }
7276 char path[CBM_SZ_1K];
7277 const char *override = getenv("CBM_INDEX_LOG");
7278 if (override && override[0]) {
7279 snprintf(path, sizeof(path), "%s", override);
7280 } else {
7281 const char *cdir = cbm_resolve_cache_dir();
7282 if (!cdir) {
7283 return false;
7284 }
7285 char logdir[CBM_SZ_1K];
7286 snprintf(logdir, sizeof(logdir), "%s/logs", cdir);
7287 cbm_mkdir_p(logdir, 0755);
7288 snprintf(path, sizeof(path), "%s/%s-%lld.log", logdir, project ? project : "index",
7289 (long long)time(NULL));
7290 }
7291 FILE *f = cbm_fopen(path, "wb");
7292 if (!f) {
7293 cbm_log_warn("index.logfile_open_fail", "path", path);
7294 return false;
7295 }
7296 int partials = 0;
7297 for (int i = 0; i < count; i++) {
7298 if (is_parse_partial(&errs[i])) {
7299 partials++;
7300 }
7301 }
7302 (void)fprintf(f, "# codebase-memory-mcp index coverage report\n");
7303 (void)fprintf(f, "# project=%s skipped=%d parse_partial=%d\n", project ? project : "",
7304 count - partials, partials);
7305 (void)fprintf(f, "# columns: phase\treason\tpath\n");
7306 for (int i = 0; i < count; i++) {
7307 (void)fprintf(f, "%s\t%s\t%s\n", errs[i].phase ? errs[i].phase : "",
7308 errs[i].reason ? errs[i].reason : "", errs[i].path ? errs[i].path : "");
7309 }
7310 (void)fclose(f);
7311 if (out_path && out_sz) {
7312 snprintf(out_path, out_sz, "%s", path);
7313 }
7314 return true;
7315}
7316
7317/* Build the success portion of the index_repository response.
7318 * 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