X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fcli%2Fbabeltrace2-cfg-cli-args.c;h=72ac4f14cef064e8fc87e586adee6570a8b8d38e;hb=1b2b6649155543b87bca6cca9b7fcafc5900dc43;hp=a332bf72168775a2fa716a820dbbbe578bf4a614;hpb=1ead9076477cc6be07b0c48ce02fa40e49ddc2f0;p=babeltrace.git diff --git a/src/cli/babeltrace2-cfg-cli-args.c b/src/cli/babeltrace2-cfg-cli-args.c index a332bf72..72ac4f14 100644 --- a/src/cli/babeltrace2-cfg-cli-args.c +++ b/src/cli/babeltrace2-cfg-cli-args.c @@ -3194,6 +3194,7 @@ static int create_implicit_component_args_from_auto_discovered_sources( const struct auto_source_discovery *auto_disc, const bt_value *leftover_params, + const bt_value *leftover_loglevels, GPtrArray *component_args) { gchar *cc_name = NULL; @@ -3221,8 +3222,8 @@ int create_implicit_component_args_from_auto_discovered_sources( } /* - * Append parameters of all the leftovers that contributed to - * this component instance coming into existence. + * Append parameters and log levels of all the leftovers that + * contributed to this component instance coming into existence. */ orig_indices_count = bt_value_array_get_size(res->original_input_indices); for (orig_indices_i = 0; orig_indices_i < orig_indices_count; orig_indices_i++) { @@ -3234,6 +3235,7 @@ int create_implicit_component_args_from_auto_discovered_sources( bt_value_array_borrow_element_by_index_const( leftover_params, orig_idx); uint64_t params_i, params_count; + const bt_value *loglevel_value; params_count = bt_value_array_get_size(params_array); for (params_i = 0; params_i < params_count; params_i++) { @@ -3257,6 +3259,27 @@ int create_implicit_component_args_from_auto_discovered_sources( goto error; } } + + loglevel_value = bt_value_array_borrow_element_by_index_const( + leftover_loglevels, orig_idx); + if (bt_value_get_type(loglevel_value) == BT_VALUE_TYPE_STRING) { + const char *loglevel = bt_value_string_get(loglevel_value); + bt_value_array_append_element_status append_status; + + append_status = bt_value_array_append_string_element( + comp->extra_params, "--log-level"); + if (append_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) { + BT_CLI_LOGE_APPEND_CAUSE("Failed to append array element."); + goto error; + } + + append_status = bt_value_array_append_string_element( + comp->extra_params, loglevel); + if (append_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) { + BT_CLI_LOGE_APPEND_CAUSE("Failed to append array element."); + goto error; + } + } } status = append_parameter_to_args(comp->extra_params, "inputs", res->inputs); @@ -3331,6 +3354,7 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[], GList *sink_names = NULL; bt_value *leftovers = NULL; bt_value *leftover_params = NULL; + bt_value *leftover_loglevels = NULL; struct implicit_component_args implicit_ctf_output_args = { 0 }; struct implicit_component_args implicit_lttng_live_args = { 0 }; struct implicit_component_args implicit_dummy_args = { 0 }; @@ -3445,6 +3469,12 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[], goto error; } + leftover_loglevels = bt_value_array_create(); + if (!leftover_loglevels) { + BT_CLI_LOGE_APPEND_CAUSE_OOM(); + goto error; + } + if (auto_source_discovery_init(&auto_disc) != 0) { goto error; } @@ -3628,20 +3658,36 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[], } break; case OPT_LOG_LEVEL: - if (current_item_type != CONVERT_CURRENT_ITEM_TYPE_COMPONENT) { - BT_CLI_LOGE_APPEND_CAUSE( - "No current component (--component option) to assign a log level to:\n %s", - arg); - goto error; - } + if (current_item_type == CONVERT_CURRENT_ITEM_TYPE_COMPONENT) { + if (bt_value_array_append_string_element(run_args, "--log-level")) { + BT_CLI_LOGE_APPEND_CAUSE_OOM(); + goto error; + } - if (bt_value_array_append_string_element(run_args, "--log-level")) { - BT_CLI_LOGE_APPEND_CAUSE_OOM(); - goto error; - } + if (bt_value_array_append_string_element(run_args, arg)) { + BT_CLI_LOGE_APPEND_CAUSE_OOM(); + goto error; + } + } else if (current_item_type == CONVERT_CURRENT_ITEM_TYPE_LEFTOVER) { + uint64_t idx = bt_value_array_get_size(leftover_loglevels) - 1; + bt_value *log_level_str_value; - if (bt_value_array_append_string_element(run_args, arg)) { - BT_CLI_LOGE_APPEND_CAUSE_OOM(); + log_level_str_value = bt_value_string_create_init(arg); + if (!log_level_str_value) { + BT_CLI_LOGE_APPEND_CAUSE_OOM(); + goto error; + } + + if (bt_value_array_set_element_by_index(leftover_loglevels, idx, + log_level_str_value)) { + bt_value_put_ref(log_level_str_value); + BT_CLI_LOGE_APPEND_CAUSE_OOM(); + goto error; + } + } else { + BT_CLI_LOGE_APPEND_CAUSE( + "No current component (--component option) or non-option argument to assign a log level to:\n %s", + arg); goto error; } @@ -3746,6 +3792,12 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[], BT_CLI_LOGE_APPEND_CAUSE_OOM(); goto error; } + + append_status = bt_value_array_append_element(leftover_loglevels, bt_value_null); + if (append_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) { + BT_CLI_LOGE_APPEND_CAUSE_OOM(); + goto error; + } } else { abort(); } @@ -4221,7 +4273,8 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[], } status = create_implicit_component_args_from_auto_discovered_sources( - &auto_disc, leftover_params, discovered_source_args); + &auto_disc, leftover_params, leftover_loglevels, + discovered_source_args); if (status != 0) { goto error; }