|
|
|
|
@ -142,33 +142,15 @@ struct UTUN_INSTANCE* utun_instance_create(struct UASYNC* ua, const char *config
|
|
|
|
|
|
|
|
|
|
// Apply debug level from config
|
|
|
|
|
if (config->global.debug_level[0]) { |
|
|
|
|
debug_level_t level = DEBUG_LEVEL_INFO; |
|
|
|
|
if (strcmp(config->global.debug_level, "error") == 0) level = DEBUG_LEVEL_ERROR; |
|
|
|
|
else if (strcmp(config->global.debug_level, "warn") == 0) level = DEBUG_LEVEL_WARN; |
|
|
|
|
else if (strcmp(config->global.debug_level, "info") == 0) level = DEBUG_LEVEL_INFO; |
|
|
|
|
else if (strcmp(config->global.debug_level, "debug") == 0) level = DEBUG_LEVEL_DEBUG; |
|
|
|
|
else if (strcmp(config->global.debug_level, "trace") == 0) level = DEBUG_LEVEL_TRACE; |
|
|
|
|
debug_set_level(level); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_CONFIG, "Applied debug_level from config: %s", config->global.debug_level); |
|
|
|
|
debug_apply_global_level(config->global.debug_level); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Apply per-category debug levels from [debug] section
|
|
|
|
|
for (int i = 0; i < config->global.debug_levels.count; i++) { |
|
|
|
|
const char* cat_name = config->global.debug_levels.category[i]; |
|
|
|
|
const char* lvl_str = config->global.debug_levels.level[i]; |
|
|
|
|
|
|
|
|
|
debug_category_t cat = get_category_by_name(cat_name); |
|
|
|
|
if (cat != DEBUG_CATEGORY_NONE) { |
|
|
|
|
debug_level_t lvl = DEBUG_LEVEL_NONE; |
|
|
|
|
if (strcmp(lvl_str, "error") == 0) lvl = DEBUG_LEVEL_ERROR; |
|
|
|
|
else if (strcmp(lvl_str, "warn") == 0) lvl = DEBUG_LEVEL_WARN; |
|
|
|
|
else if (strcmp(lvl_str, "info") == 0) lvl = DEBUG_LEVEL_INFO; |
|
|
|
|
else if (strcmp(lvl_str, "debug") == 0) lvl = DEBUG_LEVEL_DEBUG; |
|
|
|
|
else if (strcmp(lvl_str, "trace") == 0) lvl = DEBUG_LEVEL_TRACE; |
|
|
|
|
|
|
|
|
|
debug_set_category_level(cat, lvl); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_CONFIG, "Applied per-category debug: %s=%s", cat_name, lvl_str); |
|
|
|
|
} |
|
|
|
|
debug_apply_category_config( |
|
|
|
|
config->global.debug_levels.category[i], |
|
|
|
|
config->global.debug_levels.level[i] |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Allocate instance
|
|
|
|
|
|