flt.utils.muxer: honor component's initial log level
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 15 Jun 2019 06:31:40 +0000 (02:31 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 20 Jun 2019 18:01:16 +0000 (14:01 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ie0a6c76fa2c462bcd352081e98aa14411bfd13d8
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1466
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
src/cli/babeltrace2.c
src/plugins/utils/muxer/Makefile.am
src/plugins/utils/muxer/logging.c [deleted file]
src/plugins/utils/muxer/logging.h [deleted file]
src/plugins/utils/muxer/muxer.c

index dfcdd2dd14e7b7dbcdbc2ad50b46b73cc99532cc..01d1f8c523e02ce8acc3cc12923db854e7dfaae3 100644 (file)
@@ -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",
index 3eeb008a287891b4db2f90d1b061d220e53dc392..3f17d9b8fd9e58b1c3d484e72b1be9b6f34041d2 100644 (file)
@@ -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 (file)
index 1bf5383..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 (file)
index ebb3538..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef PLUGINS_UTILS_MUXER_LOGGING_H
-#define PLUGINS_UTILS_MUXER_LOGGING_H
-
-/*
- * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 */
index 90d692f2742d66fabedf87a70449ae990ed0387d..f7ea304ba8b6ab472b472c502ce8a2071a6c8fb2 100644 (file)
@@ -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) {
This page took 0.029918 seconds and 4 git commands to generate.