X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=cli%2Fbabeltrace.c;h=938aadf1fe272f3d82c8b75bf98b02698bcedec1;hb=54b8d024adaa940da85711e95f0020c0e65fd284;hp=15db3eafcc8edcadca0e6cd2220d81dc8e41c09f;hpb=fdad611f76f0819f37be88357e9e3e52cb317d81;p=babeltrace.git diff --git a/cli/babeltrace.c b/cli/babeltrace.c index 15db3eaf..938aadf1 100644 --- a/cli/babeltrace.c +++ b/cli/babeltrace.c @@ -55,18 +55,19 @@ */ static const char* log_level_env_var_names[] = { "BABELTRACE_COMMON_LOG_LEVEL", + "BABELTRACE_COMPAT_LOG_LEVEL", "BABELTRACE_PLUGIN_CTF_BTR_LOG_LEVEL", - "BABELTRACE_PLUGIN_CTF_FS_SINK_LOG_LEVEL", - "BABELTRACE_PLUGIN_CTF_FS_SRC_LOG_LEVEL", - "BABELTRACE_PLUGIN_CTF_LTTNG_LIVE_SRC_LOG_LEVEL", + "BABELTRACE_SINK_CTF_FS_LOG_LEVEL", + "BABELTRACE_SRC_CTF_FS_LOG_LEVEL", + "BABELTRACE_SRC_CTF_LTTNG_LIVE_LOG_LEVEL", "BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL", "BABELTRACE_PLUGIN_CTF_NOTIF_ITER_LOG_LEVEL", "BABELTRACE_PLUGIN_CTFCOPYTRACE_LIB_LOG_LEVEL", - "BABELTRACE_PLUGIN_LTTNG_UTILS_DEBUG_INFO_FLT_LOG_LEVEL", - "BABELTRACE_PLUGIN_TEXT_DMESG_SRC_LOG_LEVEL", - "BABELTRACE_PLUGIN_TEXT_PRETTY_SINK_LOG_LEVEL", - "BABELTRACE_PLUGIN_UTILS_MUXER_FLT_LOG_LEVEL", - "BABELTRACE_PLUGIN_UTILS_TRIMMER_FLT_LOG_LEVEL", + "BABELTRACE_FLT_LTTNG_UTILS_DEBUG_INFO_LOG_LEVEL", + "BABELTRACE_SRC_TEXT_DMESG_LOG_LEVEL", + "BABELTRACE_SINK_TEXT_PRETTY_LOG_LEVEL", + "BABELTRACE_FLT_UTILS_MUXER_LOG_LEVEL", + "BABELTRACE_FLT_UTILS_TRIMMER_LOG_LEVEL", "BABELTRACE_PYTHON_BT2_LOG_LEVEL", "BABELTRACE_PYTHON_PLUGIN_PROVIDER_LOG_LEVEL", NULL, @@ -1034,9 +1035,8 @@ int cmd_help(struct bt_config *cfg) if (cfg->cmd_data.help.cfg_component->type != BT_COMPONENT_CLASS_TYPE_UNKNOWN) { if (strcmp(cfg->cmd_data.help.cfg_component->comp_cls_name->str, - comp_class_name) != 0 && - type == - cfg->cmd_data.help.cfg_component->type) { + comp_class_name) != 0 || + type != cfg->cmd_data.help.cfg_component->type) { bt_put(comp_cls); continue; } @@ -1156,6 +1156,7 @@ int cmd_print_lttng_live_sessions(struct bt_config *cfg) BT_COMPONENT_CLASS_TYPE_SOURCE; int64_t array_size, i; const char *fail_reason = NULL; + FILE *out_stream = stdout; assert(cfg->cmd_data.print_lttng_live_sessions.url); comp_cls = find_component_class(plugin_name, comp_cls_name, @@ -1200,6 +1201,19 @@ int cmd_print_lttng_live_sessions(struct bt_config *cfg) goto error; } + if (cfg->cmd_data.print_lttng_live_sessions.output_path->len > 0) { + out_stream = + fopen(cfg->cmd_data.print_lttng_live_sessions.output_path->str, + "w"); + if (!out_stream) { + ret = -1; + BT_LOGE_ERRNO("Cannot open file for writing", + ": path=\"%s\"", + cfg->cmd_data.print_lttng_live_sessions.output_path->str); + goto end; + } + } + array_size = bt_value_array_size(results); for (i = 0; i < array_size; i++) { const char *url_text; @@ -1222,7 +1236,7 @@ int cmd_print_lttng_live_sessions(struct bt_config *cfg) } ret = bt_value_string_get(v, &url_text); assert(ret == 0); - printf("%s", url_text); + fprintf(out_stream, "%s", url_text); BT_PUT(v); v = bt_value_map_get(map, "timer-us"); @@ -1232,7 +1246,7 @@ int cmd_print_lttng_live_sessions(struct bt_config *cfg) } ret = bt_value_integer_get(v, &timer_us); assert(ret == 0); - printf(" (timer = %" PRIu64 ", ", timer_us); + fprintf(out_stream, " (timer = %" PRIu64 ", ", timer_us); BT_PUT(v); v = bt_value_map_get(map, "stream-count"); @@ -1242,7 +1256,7 @@ int cmd_print_lttng_live_sessions(struct bt_config *cfg) } ret = bt_value_integer_get(v, &streams); assert(ret == 0); - printf("%" PRIu64 " stream(s), ", streams); + fprintf(out_stream, "%" PRIu64 " stream(s), ", streams); BT_PUT(v); v = bt_value_map_get(map, "client-count"); @@ -1252,7 +1266,7 @@ int cmd_print_lttng_live_sessions(struct bt_config *cfg) } ret = bt_value_integer_get(v, &clients); assert(ret == 0); - printf("%" PRIu64 " client(s) connected)\n", clients); + fprintf(out_stream, "%" PRIu64 " client(s) connected)\n", clients); BT_PUT(v); BT_PUT(map); @@ -1277,6 +1291,17 @@ end: bt_put(results); bt_put(params); bt_put(comp_cls); + + if (out_stream && out_stream != stdout) { + int fclose_ret = fclose(out_stream); + + if (fclose_ret) { + BT_LOGE_ERRNO("Cannot close file stream", + ": path=\"%s\"", + cfg->cmd_data.print_lttng_live_sessions.output_path->str); + } + } + return 0; } @@ -1294,6 +1319,7 @@ int cmd_print_ctf_metadata(struct bt_config *cfg) static const enum bt_component_class_type comp_cls_type = BT_COMPONENT_CLASS_TYPE_SOURCE; const char *fail_reason = NULL; + FILE *out_stream = stdout; assert(cfg->cmd_data.print_ctf_metadata.path); comp_cls = find_component_class(plugin_name, comp_cls_name, @@ -1341,7 +1367,26 @@ int cmd_print_ctf_metadata(struct bt_config *cfg) ret = bt_value_string_get(metadata_text_value, &metadata_text); assert(ret == 0); - printf("%s\n", metadata_text); + + if (cfg->cmd_data.print_ctf_metadata.output_path->len > 0) { + out_stream = + fopen(cfg->cmd_data.print_ctf_metadata.output_path->str, + "w"); + if (!out_stream) { + ret = -1; + BT_LOGE_ERRNO("Cannot open file for writing", + ": path=\"%s\"", + cfg->cmd_data.print_ctf_metadata.output_path->str); + goto end; + } + } + + ret = fprintf(out_stream, "%s\n", metadata_text); + if (ret < 0) { + BT_LOGE("Cannot write whole metadata text to output stream: " + "ret=%d", ret); + } + goto end; failed: @@ -1359,6 +1404,17 @@ end: bt_put(params); bt_put(metadata_text_value); bt_put(comp_cls); + + if (out_stream && out_stream != stdout) { + int fclose_ret = fclose(out_stream); + + if (fclose_ret) { + BT_LOGE_ERRNO("Cannot close file stream", + ": path=\"%s\"", + cfg->cmd_data.print_ctf_metadata.output_path->str); + } + } + return 0; } @@ -2089,7 +2145,7 @@ int set_stream_intersections(struct cmd_run_ctx *ctx, value_status = bt_value_map_insert(query_params, "path", component_path_value); if (value_status != BT_VALUE_STATUS_OK) { - BT_LOGE_STR("Cannot insert path parameter in query paramater map."); + BT_LOGE_STR("Cannot insert path parameter in query parameter map."); ret = -1; goto error; }