X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=cli%2Fbabeltrace.c;h=66c74df44b85ca8024f2ef99cc5e07bd3232bbd0;hb=f384901f99784474c5c013dd16b4333d9125dfd5;hp=f63150a273632ff6d753592cd2ba854143339856;hpb=0d107cdd376ff07c7bc6da9dfd46d57463442df1;p=babeltrace.git diff --git a/cli/babeltrace.c b/cli/babeltrace.c index f63150a2..66c74df4 100644 --- a/cli/babeltrace.c +++ b/cli/babeltrace.c @@ -26,6 +26,9 @@ * SOFTWARE. */ +#define BT_LOG_TAG "CLI" +#include "logging.h" + #include #include #include @@ -54,9 +57,6 @@ #include "babeltrace-cfg-cli-args.h" #include "babeltrace-cfg-cli-args-default.h" -#define BT_LOG_TAG "CLI" -#include "logging.h" - #define ENV_BABELTRACE_WARN_COMMAND_NAME_DIRECTORY_CLASH "BABELTRACE_CLI_WARN_COMMAND_NAME_DIRECTORY_CLASH" /* Application's processing graph (weak) */ @@ -65,9 +65,6 @@ static bool canceled = false; GPtrArray *loaded_plugins; -BT_HIDDEN -int bt_cli_log_level = BT_LOG_NONE; - static void sigint_handler(int signum) { @@ -581,6 +578,19 @@ int load_dynamic_plugins(struct bt_value *plugin_paths) plugin_path_value = bt_value_array_get(plugin_paths, i); bt_value_string_get(plugin_path_value, &plugin_path); assert(plugin_path); + + /* + * Skip this if the directory does not exist because + * bt_plugin_create_all_from_dir() expects an existing + * directory. + */ + if (!g_file_test(plugin_path, G_FILE_TEST_IS_DIR)) { + BT_LOGV("Skipping nonexistent directory path: " + "path=\"%s\"", plugin_path); + BT_PUT(plugin_path_value); + continue; + } + plugin_set = bt_plugin_create_all_from_dir(plugin_path, false); if (!plugin_set) { BT_LOGD("Unable to load dynamic plugins: path=\"%s\"", @@ -1180,7 +1190,7 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( cfg_conn->downstream_comp_name->str); assert(downstreamp_comp_name_quark > 0); downstream_comp = g_hash_table_lookup(ctx->components, - (gpointer) (long) downstreamp_comp_name_quark); + GUINT_TO_POINTER(downstreamp_comp_name_quark)); if (!downstream_comp) { BT_LOGE("Cannot find downstream component: comp-name=\"%s\", " "conn-arg=\"%s\"", cfg_conn->downstream_comp_name->str, @@ -1586,7 +1596,7 @@ int cmd_run_ctx_create_components_from_config_components( quark = g_quark_from_string(cfg_comp->instance_name->str); assert(quark > 0); g_hash_table_insert(ctx->components, - (gpointer) (long) quark, comp); + GUINT_TO_POINTER(quark), comp); comp = NULL; BT_PUT(comp_cls); } @@ -1736,6 +1746,13 @@ int cmd_run(struct bt_config *cfg) goto error; } + if (canceled) { + BT_LOGI_STR("Canceled by user before creating components."); + goto error; + } + + BT_LOGI_STR("Creating components."); + /* Create the requested component instances */ if (cmd_run_ctx_create_components(&ctx)) { BT_LOGE_STR("Cannot create components."); @@ -1743,6 +1760,13 @@ int cmd_run(struct bt_config *cfg) goto error; } + if (canceled) { + BT_LOGI_STR("Canceled by user before connecting components."); + goto error; + } + + BT_LOGI_STR("Connecting components."); + /* Connect the initially visible component ports */ if (cmd_run_ctx_connect_ports(&ctx)) { BT_LOGE_STR("Cannot connect initial component ports."); @@ -1751,7 +1775,8 @@ int cmd_run(struct bt_config *cfg) } if (canceled) { - goto end; + BT_LOGI_STR("Canceled by user before running the graph."); + goto error; } BT_LOGI_STR("Running the graph."); @@ -1845,31 +1870,7 @@ void warn_command_name_and_directory_clash(struct bt_config *cfg) static void init_log_level(void) { - enum bt_logging_level log_level = BT_LOG_NONE; - const char *log_level_env = getenv("BABELTRACE_CLI_LOG_LEVEL"); - - if (!log_level_env) { - goto set_level; - } - - if (strcmp(log_level_env, "VERBOSE") == 0) { - log_level = BT_LOGGING_LEVEL_VERBOSE; - } else if (strcmp(log_level_env, "DEBUG") == 0) { - log_level = BT_LOGGING_LEVEL_DEBUG; - } else if (strcmp(log_level_env, "INFO") == 0) { - log_level = BT_LOGGING_LEVEL_INFO; - } else if (strcmp(log_level_env, "WARN") == 0) { - log_level = BT_LOGGING_LEVEL_WARN; - } else if (strcmp(log_level_env, "ERROR") == 0) { - log_level = BT_LOGGING_LEVEL_ERROR; - } else if (strcmp(log_level_env, "FATAL") == 0) { - log_level = BT_LOGGING_LEVEL_FATAL; - } else if (strcmp(log_level_env, "NONE") == 0) { - log_level = BT_LOGGING_LEVEL_NONE; - } - -set_level: - bt_cli_log_level = log_level; + bt_cli_log_level = bt_log_get_level_from_env("BABELTRACE_CLI_LOG_LEVEL"); } void set_sigint_handler(void)