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

Function handle_ui_log_get

src/ui/http_server.c:1047–1070  ·  view source on GitHub ↗

GET /api/ui-log preserves the original lines[] contract, read from SQLite. * The JSONL paths are compatibility exports, never an independent status source. */

Source from the content-addressed store, hash-verified

1045/* GET /api/ui-log preserves the original lines[] contract, read from SQLite.
1046 * The JSONL paths are compatibility exports, never an independent status source. */
1047static void handle_ui_log_get(cbm_http_conn_t *c, const cbm_http_req_t *req) {
1048 char lines_str[16] = {0};
1049 int max_lines = UI_LOG_TAIL_DEFAULT_LINES;
1050 if (cbm_http_query_param(req->query, "lines", lines_str, (int)sizeof(lines_str))) {
1051 int v = atoi(lines_str);
1052 if (v > 0 && v <= UI_LOG_TAIL_MAX_LINES)
1053 max_lines = v;
1054 }
1055 char path[CBM_SZ_1K], previous[CBM_SZ_1K + 8];
1056 if (!cbm_ui_log_file_path(path, sizeof(path))) {
1057 cbm_http_replyf(c, 500, g_cors_json, "{\"error\":\"no log path\"}");
1058 return;
1059 }
1060 snprintf(previous, sizeof(previous), "%s.1", path);
1061 cbm_ui_log_init();
1062 cbm_mutex_lock(&g_log_mutex);
1063 sqlite3 *db = activity_db_locked();
1064 char *json = cbm_activity_ui_logs(db, max_lines, g_activity_path, path,
1065 cbm_file_exists(previous) ? previous : NULL);
1066 cbm_mutex_unlock(&g_log_mutex);
1067 cbm_http_replyf(c, json ? 200 : 503, g_cors_json, "%s",
1068 json ? json : "{\"error\":\"activity storage unavailable\"}");
1069 cbm_free(CBM_MEM_CLASS_OTHER, json);
1070}
1071
1072/* ── Process monitoring ───────────────────────────────────────── */
1073

Callers 1

dispatch_requestFunction · 0.85

Calls 10

cbm_http_query_paramFunction · 0.85
cbm_ui_log_file_pathFunction · 0.85
cbm_http_replyfFunction · 0.85
cbm_ui_log_initFunction · 0.85
cbm_mutex_lockFunction · 0.85
activity_db_lockedFunction · 0.85
cbm_activity_ui_logsFunction · 0.85
cbm_file_existsFunction · 0.85
cbm_mutex_unlockFunction · 0.85
cbm_freeFunction · 0.85

Tested by

no test coverage detected