Browse Source

c

nodeinfo-routing-update
Evgeny 1 month ago
parent
commit
55828da328
  1. 77
      lib/debug_config.c
  2. BIN
      tests/bench_timeout_heap
  3. BIN
      tests/bench_uasync_timeouts

77
lib/debug_config.c

@ -327,13 +327,13 @@ void debug_output(debug_level_t level, debug_category_t category,
#undef BUFFER_SIZE #undef BUFFER_SIZE
} }
/* Parse debug configuration from string */ /* Parse debug configuration from string (e.g., "ll_queue:debug,uasync:info,memory:warn,etcp:error") */
int debug_parse_config(const char* config_string) { int debug_parse_config(const char* config_string) {
if (!config_string || !*config_string) { if (!config_string || !*config_string) {
return 0; return 0;
} }
char* str = strdup(config_string); char* str = u_strdup(config_string);
if (!str) { if (!str) {
return -1; return -1;
} }
@ -341,60 +341,63 @@ int debug_parse_config(const char* config_string) {
debug_category_t categories = 0; debug_category_t categories = 0;
debug_level_t level = DEBUG_LEVEL_NONE; debug_level_t level = DEBUG_LEVEL_NONE;
char* token = strtok(str, ";"); char* token = strtok(str, ",");
while (token) { while (token) {
/* Trim leading spaces */ /* Trim leading spaces */
while (isspace(*token)) { while (isspace(*token)) {
token++; token++;
} }
char* eq = strchr(token, '='); char* colon = strchr(token, ':');
if (!eq) { if (!colon) {
u_free(str); u_free(str);
return -1; return -1;
} }
*eq = '\0'; *colon = '\0';
char* key = token; char* category_name = token;
char* value = eq + 1; char* level_name = colon + 1;
/* Trim leading spaces in value */ /* Trim leading spaces in level_name */
while (isspace(*value)) { while (isspace(*level_name)) {
value++; level_name++;
} }
if (strcasecmp(key, "modules") == 0) { debug_category_t cat = get_category_by_name(category_name);
char* mod_token = strtok(value, ","); if (cat == DEBUG_CATEGORY_NONE) {
while (mod_token) { u_free(str);
/* Trim leading spaces */ return -1;
while (isspace(*mod_token)) { }
mod_token++;
} debug_level_t lev = DEBUG_LEVEL_NONE;
if (strcasecmp(level_name, "none") == 0) {
debug_category_t cat = get_category_by_name(mod_token); lev = DEBUG_LEVEL_NONE;
if (cat == DEBUG_CATEGORY_NONE) { } else if (strcasecmp(level_name, "error") == 0) {
u_free(str); lev = DEBUG_LEVEL_ERROR;
return -1; } else if (strcasecmp(level_name, "warn") == 0) {
} lev = DEBUG_LEVEL_WARN;
categories |= cat; } else if (strcasecmp(level_name, "info") == 0) {
mod_token = strtok(NULL, ","); lev = DEBUG_LEVEL_INFO;
} } else if (strcasecmp(level_name, "debug") == 0) {
} else if (strcasecmp(key, "level") == 0) { lev = DEBUG_LEVEL_DEBUG;
int lev_num = atoi(value); } else if (strcasecmp(level_name, "trace") == 0) {
if (lev_num < DEBUG_LEVEL_NONE || lev_num > DEBUG_LEVEL_TRACE) { lev = DEBUG_LEVEL_TRACE;
u_free(str);
return -1;
}
level = (debug_level_t)lev_num;
} else { } else {
u_free(str); u_free(str);
return -1; return -1;
} }
token = strtok(NULL, ";"); /* Set per-category level */
} int idx = 0;
while (!(cat & (1ULL << idx)) && idx < DEBUG_CATEGORY_COUNT) {
idx++;
}
if (idx < DEBUG_CATEGORY_COUNT) {
g_debug_config.category_levels[idx] = lev;
}
debug_set_masks(categories, level); token = strtok(NULL, ",");
}
u_free(str); u_free(str);
return 0; return 0;

BIN
tests/bench_timeout_heap

Binary file not shown.

BIN
tests/bench_uasync_timeouts

Binary file not shown.
Loading…
Cancel
Save