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. */
| 7400 | * $CBM_INDEX_LOG (override) else <cache_dir>/logs/<project>-<epoch>.log |
| 7401 | * Returns true and fills out_path on success. */ |
| 7402 | static 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). */ |
no test coverage detected