From 6563da7aae6e3aa1d574bac15f3284a7dd9f862d Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 9 Mar 2022 11:47:04 -0500 Subject: [PATCH] sink.text.details: show stream class namespace If the stream class has a namespace (a property introduced with MIP 1), show it when dumping the stream class info. Add a `with-stream-class-namespace` parameter to the component class, controlling whether to show the namespace or not. Example output: Trace class: Stream class `da-name` (Namespace `da-namespace`, ID 0): Philippe updated the manual page to document the `with-stream-class-namespace` parameter. Change-Id: I1a3854d266f8f7a87be09ed44c70e03ac9cc6912 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/7529 Reviewed-by: Philippe Proulx Tested-by: jenkins Reviewed-on: https://review.lttng.org/c/babeltrace/+/12693 --- doc/man/babeltrace2-sink.text.details.7.txt | 9 +++++++-- src/plugins/text/details/details.c | 8 ++++++++ src/plugins/text/details/details.h | 3 +++ src/plugins/text/details/write.c | 17 +++++++++++++++-- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/doc/man/babeltrace2-sink.text.details.7.txt b/doc/man/babeltrace2-sink.text.details.7.txt index 8a23dd4e..b696d5d8 100644 --- a/doc/man/babeltrace2-sink.text.details.7.txt +++ b/doc/man/babeltrace2-sink.text.details.7.txt @@ -85,8 +85,8 @@ objects which it did not print yet. You can use the param:with-metadata parameter to disable this. You can hide specific properties with the param:with-stream-class-name, -param:with-stream-name, param:with-time, param:with-trace-name, and -param:with-uuid parameters. +param:with-stream-class-namespace, param:with-stream-name, +param:with-time, param:with-trace-name, and param:with-uuid parameters. To make the component hide many message details and print a single message per line, you can enable the compact mode with the param:compact @@ -135,6 +135,11 @@ param:with-stream-class-name='VAL' vtype:[optional boolean]:: + Default: true. +param:with-stream-class-namespace='VAL' vtype:[optional boolean]:: + If 'VAL' is false, then do not print stream class namespaces. ++ +Default: true. + param:with-stream-name='VAL' vtype:[optional boolean]:: If 'VAL' is false, then do not print stream names. + diff --git a/src/plugins/text/details/details.c b/src/plugins/text/details/details.c index a685e201..c484e055 100644 --- a/src/plugins/text/details/details.c +++ b/src/plugins/text/details/details.c @@ -26,6 +26,7 @@ #define WITH_TIME_PARAM_NAME "with-time" #define WITH_TRACE_NAME_PARAM_NAME "with-trace-name" #define WITH_STREAM_CLASS_NAME_PARAM_NAME "with-stream-class-name" +#define WITH_STREAM_CLASS_NAMESPACE_PARAM_NAME "with-stream-class-namespace" #define WITH_STREAM_NAME_PARAM_NAME "with-stream-name" #define WITH_UUID_PARAM_NAME "with-uuid" #define COMPACT_PARAM_NAME "compact" @@ -222,6 +223,7 @@ static const struct bt_param_validation_map_value_entry_descr details_params[] = { COMPACT_PARAM_NAME, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_BOOL } }, { WITH_TIME_PARAM_NAME, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_BOOL } }, { WITH_TRACE_NAME_PARAM_NAME, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_BOOL } }, + { WITH_STREAM_CLASS_NAMESPACE_PARAM_NAME, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_BOOL } }, { WITH_STREAM_CLASS_NAME_PARAM_NAME, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_BOOL } }, { WITH_STREAM_NAME_PARAM_NAME, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_BOOL } }, { WITH_UUID_PARAM_NAME, BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_OPTIONAL, { .type = BT_VALUE_TYPE_BOOL } }, @@ -293,6 +295,10 @@ bt_component_class_initialize_method_status configure_details_comp( configure_bool_opt(params, WITH_STREAM_CLASS_NAME_PARAM_NAME, true, &details_comp->cfg.with_stream_class_name); + /* With stream class namespace? */ + configure_bool_opt(params, WITH_STREAM_CLASS_NAMESPACE_PARAM_NAME, true, + &details_comp->cfg.with_stream_class_ns); + /* With stream name? */ configure_bool_opt(params, WITH_STREAM_NAME_PARAM_NAME, true, &details_comp->cfg.with_stream_name); @@ -322,6 +328,8 @@ void log_configuration(bt_self_component_sink *comp, BT_COMP_LOGI(" With metadata: %d", details_comp->cfg.with_meta); BT_COMP_LOGI(" With time: %d", details_comp->cfg.with_time); BT_COMP_LOGI(" With trace name: %d", details_comp->cfg.with_trace_name); + BT_COMP_LOGI(" With stream class namespace: %d", + details_comp->cfg.with_stream_class_ns); BT_COMP_LOGI(" With stream class name: %d", details_comp->cfg.with_stream_class_name); BT_COMP_LOGI(" With stream name: %d", details_comp->cfg.with_stream_name); diff --git a/src/plugins/text/details/details.h b/src/plugins/text/details/details.h index 89bddad8..6adda8a6 100644 --- a/src/plugins/text/details/details.h +++ b/src/plugins/text/details/details.h @@ -88,6 +88,9 @@ struct details_comp { /* Write trace's name */ bool with_trace_name; + /* Write stream class's namespace */ + bool with_stream_class_ns; + /* Write stream class's name */ bool with_stream_class_name; diff --git a/src/plugins/text/details/write.c b/src/plugins/text/details/write.c index df3f28a9..5cc023c0 100644 --- a/src/plugins/text/details/write.c +++ b/src/plugins/text/details/write.c @@ -1516,7 +1516,7 @@ void write_stream_class(struct details_write_ctx *ctx, write_indent(ctx); write_obj_type_name(ctx, "Stream class"); - /* Write name and ID */ + /* Write name, namespace and ID */ if (ctx->details_comp->cfg.with_stream_class_name) { const char *name = bt_stream_class_get_name(sc); @@ -1527,7 +1527,20 @@ void write_stream_class(struct details_write_ctx *ctx, } } - g_string_append(ctx->str, " (ID "); + g_string_append(ctx->str, " ("); + + if (ctx->details_comp->cfg.with_stream_class_ns + && ctx->details_comp->mip_version >= 1) { + const char *ns = bt_stream_class_get_namespace(sc); + + if (ns) { + g_string_append(ctx->str, "Namespace `"); + write_str_prop_value(ctx, ns); + g_string_append(ctx->str, "`, "); + } + } + + g_string_append(ctx->str, "ID "); write_uint_prop_value(ctx, bt_stream_class_get_id(sc)); g_string_append(ctx->str, "):\n"); -- 2.34.1