From f5abbab425b89b8ed32968d88c5faf82afe82bd3 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Sat, 15 Jun 2019 02:31:40 -0400 Subject: [PATCH] flt.utils.muxer: honor component's initial log level Signed-off-by: Philippe Proulx Change-Id: Ie0a6c76fa2c462bcd352081e98aa14411bfd13d8 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1466 Tested-by: jenkins Reviewed-by: Francis Deslauriers --- src/cli/babeltrace2.c | 1 - src/plugins/utils/muxer/Makefile.am | 2 +- src/plugins/utils/muxer/logging.c | 27 ------------------ src/plugins/utils/muxer/logging.h | 31 -------------------- src/plugins/utils/muxer/muxer.c | 44 ++++++++++++++++++++++++----- 5 files changed, 38 insertions(+), 67 deletions(-) delete mode 100644 src/plugins/utils/muxer/logging.c delete mode 100644 src/plugins/utils/muxer/logging.h diff --git a/src/cli/babeltrace2.c b/src/cli/babeltrace2.c index dfcdd2dd..01d1f8c5 100644 --- a/src/cli/babeltrace2.c +++ b/src/cli/babeltrace2.c @@ -50,7 +50,6 @@ */ static const char* log_level_env_var_names[] = { "BABELTRACE_FLT_LTTNG_UTILS_DEBUG_INFO_LOG_LEVEL", - "BABELTRACE_FLT_UTILS_MUXER_LOG_LEVEL", "BABELTRACE_FLT_UTILS_TRIMMER_LOG_LEVEL", "BABELTRACE_PLUGIN_CTF_BFCR_LOG_LEVEL", "BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL", diff --git a/src/plugins/utils/muxer/Makefile.am b/src/plugins/utils/muxer/Makefile.am index 3eeb008a..3f17d9b8 100644 --- a/src/plugins/utils/muxer/Makefile.am +++ b/src/plugins/utils/muxer/Makefile.am @@ -1,2 +1,2 @@ noinst_LTLIBRARIES = libbabeltrace2-plugin-muxer.la -libbabeltrace2_plugin_muxer_la_SOURCES = muxer.c muxer.h logging.c logging.h +libbabeltrace2_plugin_muxer_la_SOURCES = muxer.c muxer.h diff --git a/src/plugins/utils/muxer/logging.c b/src/plugins/utils/muxer/logging.c deleted file mode 100644 index 1bf5383c..00000000 --- a/src/plugins/utils/muxer/logging.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2017 Philippe Proulx - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#define BT_LOG_OUTPUT_LEVEL bt_plugin_utils_muxer_log_level -#include "logging/log.h" - -BT_LOG_INIT_LOG_LEVEL(bt_plugin_utils_muxer_log_level, - "BABELTRACE_FLT_UTILS_MUXER_LOG_LEVEL"); diff --git a/src/plugins/utils/muxer/logging.h b/src/plugins/utils/muxer/logging.h deleted file mode 100644 index ebb3538a..00000000 --- a/src/plugins/utils/muxer/logging.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef PLUGINS_UTILS_MUXER_LOGGING_H -#define PLUGINS_UTILS_MUXER_LOGGING_H - -/* - * Copyright (c) 2017 Philippe Proulx - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#define BT_LOG_OUTPUT_LEVEL bt_plugin_utils_muxer_log_level -#include "logging/log.h" - -BT_LOG_LEVEL_EXTERN_SYMBOL(bt_plugin_utils_muxer_log_level); - -#endif /* PLUGINS_UTILS_MUXER_LOGGING_H */ diff --git a/src/plugins/utils/muxer/muxer.c b/src/plugins/utils/muxer/muxer.c index 90d692f2..f7ea304b 100644 --- a/src/plugins/utils/muxer/muxer.c +++ b/src/plugins/utils/muxer/muxer.c @@ -20,8 +20,9 @@ * SOFTWARE. */ +#define BT_LOG_OUTPUT_LEVEL (muxer_comp->log_level) #define BT_LOG_TAG "PLUGIN/FLT.UTILS.MUXER" -#include "logging.h" +#include "logging/log.h" #include "common/macros.h" #include "compat/uuid.h" @@ -46,9 +47,12 @@ struct muxer_comp { size_t available_input_ports; bool initializing_muxer_msg_iter; bool assume_absolute_clock_classes; + bt_logging_level log_level; }; struct muxer_upstream_msg_iter { + struct muxer_comp *muxer_comp; + /* Owned by this, NULL if ended */ bt_self_component_port_input_message_iterator *msg_iter; @@ -65,6 +69,8 @@ enum muxer_msg_iter_clock_class_expectation { }; struct muxer_msg_iter { + struct muxer_comp *muxer_comp; + /* * Array of struct muxer_upstream_msg_iter * (owned by this). * @@ -112,10 +118,13 @@ static void destroy_muxer_upstream_msg_iter( struct muxer_upstream_msg_iter *muxer_upstream_msg_iter) { + struct muxer_comp *muxer_comp; + if (!muxer_upstream_msg_iter) { return; } + muxer_comp = muxer_upstream_msg_iter->muxer_comp; BT_LOGD("Destroying muxer's upstream message iterator wrapper: " "addr=%p, msg-iter-addr=%p, queue-len=%u", muxer_upstream_msg_iter, @@ -139,12 +148,14 @@ int muxer_msg_iter_add_upstream_msg_iter(struct muxer_msg_iter *muxer_msg_iter, int ret = 0; struct muxer_upstream_msg_iter *muxer_upstream_msg_iter = g_new0(struct muxer_upstream_msg_iter, 1); + struct muxer_comp *muxer_comp = muxer_msg_iter->muxer_comp; if (!muxer_upstream_msg_iter) { BT_LOGE_STR("Failed to allocate one muxer's upstream message iterator wrapper."); goto error; } + muxer_upstream_msg_iter->muxer_comp = muxer_comp; muxer_upstream_msg_iter->msg_iter = self_msg_iter; bt_self_component_port_input_message_iterator_get_ref(muxer_upstream_msg_iter->msg_iter); muxer_upstream_msg_iter->msgs = g_queue_new(); @@ -231,7 +242,7 @@ void destroy_muxer_comp(struct muxer_comp *muxer_comp) } static -bt_value *get_default_params(void) +bt_value *get_default_params(struct muxer_comp *muxer_comp) { bt_value *params; int ret; @@ -268,7 +279,7 @@ int configure_muxer_comp(struct muxer_comp *muxer_comp, int ret = 0; bt_bool bool_val; - default_params = get_default_params(); + default_params = get_default_params(muxer_comp); if (!default_params) { BT_LOGE("Cannot get default parameters: " "muxer-comp-addr=%p", muxer_comp); @@ -320,15 +331,21 @@ bt_self_component_status muxer_init( int ret; bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; struct muxer_comp *muxer_comp = g_new0(struct muxer_comp, 1); + bt_logging_level log_level = bt_component_get_logging_level( + bt_self_component_as_component( + bt_self_component_filter_as_self_component(self_comp))); - BT_LOGI("Initializing muxer component: " + BT_LOG_WRITE_CUR_LVL(BT_LOG_INFO, log_level, BT_LOG_TAG, + "Initializing muxer component: " "comp-addr=%p, params-addr=%p", self_comp, params); if (!muxer_comp) { - BT_LOGE_STR("Failed to allocate one muxer component."); + BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG, + "Failed to allocate one muxer component."); goto error; } + muxer_comp->log_level = log_level; ret = configure_muxer_comp(muxer_comp, params); if (ret) { BT_LOGE("Cannot configure muxer component: " @@ -392,7 +409,8 @@ void muxer_finalize(bt_self_component_filter *self_comp) static bt_self_component_port_input_message_iterator * -create_msg_iter_on_input_port(bt_self_component_port_input *self_port) +create_msg_iter_on_input_port(struct muxer_comp *muxer_comp, + bt_self_component_port_input *self_port) { const bt_port *port = bt_self_component_port_as_port( bt_self_component_port_input_as_self_component_port( @@ -428,6 +446,8 @@ bt_self_message_iterator_status muxer_upstream_msg_iter_next( struct muxer_upstream_msg_iter *muxer_upstream_msg_iter, bool *is_ended) { + struct muxer_comp *muxer_comp = + muxer_upstream_msg_iter->muxer_comp; bt_self_message_iterator_status status; bt_message_iterator_status input_port_iter_status; bt_message_array_const msgs; @@ -970,6 +990,8 @@ bt_self_message_iterator_status validate_muxer_upstream_msg_iter( struct muxer_upstream_msg_iter *muxer_upstream_msg_iter, bool *is_ended) { + struct muxer_comp *muxer_comp = + muxer_upstream_msg_iter->muxer_comp; bt_self_message_iterator_status status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; @@ -998,6 +1020,7 @@ static bt_self_message_iterator_status validate_muxer_upstream_msg_iters( struct muxer_msg_iter *muxer_msg_iter) { + struct muxer_comp *muxer_comp = muxer_msg_iter->muxer_comp; bt_self_message_iterator_status status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; size_t i; @@ -1173,10 +1196,13 @@ bt_self_message_iterator_status muxer_msg_iter_do_next( static void destroy_muxer_msg_iter(struct muxer_msg_iter *muxer_msg_iter) { + struct muxer_comp *muxer_comp; + if (!muxer_msg_iter) { return; } + muxer_comp = muxer_msg_iter->muxer_comp; BT_LOGD("Destroying muxer component's message iterator: " "muxer-msg-iter-addr=%p", muxer_msg_iter); @@ -1231,7 +1257,8 @@ int muxer_msg_iter_init_upstream_iterators(struct muxer_comp *muxer_comp, continue; } - upstream_msg_iter = create_msg_iter_on_input_port(self_port); + upstream_msg_iter = create_msg_iter_on_input_port(muxer_comp, + self_port); if (!upstream_msg_iter) { /* create_msg_iter_on_input_port() logs errors */ BT_ASSERT(!upstream_msg_iter); @@ -1291,6 +1318,7 @@ bt_self_message_iterator_status muxer_msg_iter_init( goto error; } + muxer_msg_iter->muxer_comp = muxer_comp; muxer_msg_iter->last_returned_ts_ns = INT64_MIN; muxer_msg_iter->active_muxer_upstream_msg_iters = g_ptr_array_new_with_free_func( @@ -1405,6 +1433,8 @@ bt_self_component_status muxer_input_port_connected( const bt_port_output *other_port) { bt_self_component_status status; + struct muxer_comp *muxer_comp = bt_self_component_get_data( + bt_self_component_filter_as_self_component(self_comp)); status = add_available_input_port(self_comp); if (status) { -- 2.34.1