flt.utils.trimmer: honor component's initial log level
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 15 Jun 2019 06:39:50 +0000 (02:39 -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: I785a46dad409a9d1ab75426ce49059169e47c74e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1467
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
src/cli/babeltrace2.c
src/plugins/utils/trimmer/Makefile.am
src/plugins/utils/trimmer/logging.c [deleted file]
src/plugins/utils/trimmer/logging.h [deleted file]
src/plugins/utils/trimmer/trimmer.c

index 01d1f8c523e02ce8acc3cc12923db854e7dfaae3..0a3cb5b9f0a0240e0ed3e40f3aa15b7c7d185496 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_TRIMMER_LOG_LEVEL",
        "BABELTRACE_PLUGIN_CTF_BFCR_LOG_LEVEL",
        "BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL",
        "BABELTRACE_PLUGIN_CTF_MSG_ITER_LOG_LEVEL",
index 9ce4c9b204338f736402fc94e4878f618c9fd589..d9144c2ff29c6181d5e9288dc25380689821c15f 100644 (file)
@@ -1,6 +1,4 @@
 noinst_LTLIBRARIES = libbabeltrace2-plugin-trimmer.la
 libbabeltrace2_plugin_trimmer_la_SOURCES = \
        trimmer.c \
-       trimmer.h \
-       logging.c \
-       logging.h
+       trimmer.h
diff --git a/src/plugins/utils/trimmer/logging.c b/src/plugins/utils/trimmer/logging.c
deleted file mode 100644 (file)
index f672123..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_trimmer_log_level
-#include "logging/log.h"
-
-BT_LOG_INIT_LOG_LEVEL(bt_plugin_utils_trimmer_log_level,
-       "BABELTRACE_FLT_UTILS_TRIMMER_LOG_LEVEL");
diff --git a/src/plugins/utils/trimmer/logging.h b/src/plugins/utils/trimmer/logging.h
deleted file mode 100644 (file)
index aba659b..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef PLUGINS_UTILS_TRIMMER_LOGGING_H
-#define PLUGINS_UTILS_TRIMMER_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_trimmer_log_level
-#include "logging/log.h"
-
-BT_LOG_LEVEL_EXTERN_SYMBOL(bt_plugin_utils_trimmer_log_level);
-
-#endif /* PLUGINS_UTILS_TRIMMER_LOGGING_H */
index fb1a2a703dce958359c35c4755fb7b5fe2e47942..cc91ff897e3476ac3241d9520fdfda50b25a9633 100644 (file)
@@ -21,8 +21,9 @@
  * SOFTWARE.
  */
 
+#define BT_LOG_OUTPUT_LEVEL (trimmer_comp->log_level)
 #define BT_LOG_TAG "PLUGIN/FLT.UTILS.TRIMMER"
-#include "logging.h"
+#include "logging/log.h"
 
 #include "compat/utc.h"
 #include "compat/time.h"
@@ -70,6 +71,7 @@ struct trimmer_bound {
 struct trimmer_comp {
        struct trimmer_bound begin, end;
        bool is_gmt;
+       bt_logging_level log_level;
 };
 
 enum trimmer_iterator_state {
@@ -238,8 +240,8 @@ end:
  * TODO: Check overflows.
  */
 static
-int set_bound_from_str(const char *str, struct trimmer_bound *bound,
-               bool is_gmt)
+int set_bound_from_str(struct trimmer_comp *trimmer_comp,
+               const char *str, struct trimmer_bound *bound, bool is_gmt)
 {
        int ret = 0;
        int s_ret;
@@ -350,7 +352,8 @@ end:
  * Returns a negative value if anything goes wrong.
  */
 static
-int set_bound_from_param(const char *param_name, const bt_value *param,
+int set_bound_from_param(struct trimmer_comp *trimmer_comp,
+               const char *param_name, const bt_value *param,
                struct trimmer_bound *bound, bool is_gmt)
 {
        int ret;
@@ -375,15 +378,15 @@ int set_bound_from_param(const char *param_name, const bt_value *param,
                goto end;
        }
 
-       ret = set_bound_from_str(arg, bound, is_gmt);
+       ret = set_bound_from_str(trimmer_comp, arg, bound, is_gmt);
 
 end:
        return ret;
 }
 
 static
-int validate_trimmer_bounds(struct trimmer_bound *begin,
-               struct trimmer_bound *end)
+int validate_trimmer_bounds(struct trimmer_comp *trimmer_comp,
+               struct trimmer_bound *begin, struct trimmer_bound *end)
 {
        int ret = 0;
 
@@ -436,7 +439,7 @@ int init_trimmer_comp_from_params(struct trimmer_comp *trimmer_comp,
 
         value = bt_value_map_borrow_entry_value_const(params, "begin");
        if (value) {
-               if (set_bound_from_param("begin", value,
+               if (set_bound_from_param(trimmer_comp, "begin", value,
                                &trimmer_comp->begin, trimmer_comp->is_gmt)) {
                        /* set_bound_from_param() logs errors */
                        ret = BT_SELF_COMPONENT_STATUS_ERROR;
@@ -449,7 +452,7 @@ int init_trimmer_comp_from_params(struct trimmer_comp *trimmer_comp,
 
         value = bt_value_map_borrow_entry_value_const(params, "end");
        if (value) {
-               if (set_bound_from_param("end", value,
+               if (set_bound_from_param(trimmer_comp, "end", value,
                                &trimmer_comp->end, trimmer_comp->is_gmt)) {
                        /* set_bound_from_param() logs errors */
                        ret = BT_SELF_COMPONENT_STATUS_ERROR;
@@ -463,8 +466,8 @@ int init_trimmer_comp_from_params(struct trimmer_comp *trimmer_comp,
 end:
        if (trimmer_comp->begin.is_set && trimmer_comp->end.is_set) {
                /* validate_trimmer_bounds() logs errors */
-               ret = validate_trimmer_bounds(&trimmer_comp->begin,
-                       &trimmer_comp->end);
+               ret = validate_trimmer_bounds(trimmer_comp,
+                       &trimmer_comp->begin, &trimmer_comp->end);
        }
 
        return ret;
@@ -482,6 +485,9 @@ bt_self_component_status trimmer_init(bt_self_component_filter *self_comp,
                goto error;
        }
 
+       trimmer_comp->log_level = bt_component_get_logging_level(
+               bt_self_component_as_component(
+                       bt_self_component_filter_as_self_component(self_comp)));
        status = bt_self_component_filter_add_input_port(
                self_comp, in_port_name, NULL, NULL);
        if (status != BT_SELF_COMPONENT_STATUS_OK) {
@@ -760,9 +766,11 @@ void put_messages(bt_message_array_const msgs, uint64_t count)
 }
 
 static inline
-int set_trimmer_iterator_bound(struct trimmer_bound *bound,
-               int64_t ns_from_origin, bool is_gmt)
+int set_trimmer_iterator_bound(struct trimmer_iterator *trimmer_it,
+               struct trimmer_bound *bound, int64_t ns_from_origin,
+               bool is_gmt)
 {
+       struct trimmer_comp *trimmer_comp = trimmer_it->trimmer_comp;
        struct tm tm;
        time_t time_seconds = (time_t) (ns_from_origin / NS_PER_S);
        int ret = 0;
@@ -843,7 +851,7 @@ bt_self_message_iterator_status state_set_trimmer_iterator_bounds(
 found:
        if (!trimmer_it->begin.is_set) {
                BT_ASSERT(!trimmer_it->begin.is_infinite);
-               ret = set_trimmer_iterator_bound(&trimmer_it->begin,
+               ret = set_trimmer_iterator_bound(trimmer_it, &trimmer_it->begin,
                        ns_from_origin, trimmer_comp->is_gmt);
                if (ret) {
                        goto error;
@@ -852,15 +860,15 @@ found:
 
        if (!trimmer_it->end.is_set) {
                BT_ASSERT(!trimmer_it->end.is_infinite);
-               ret = set_trimmer_iterator_bound(&trimmer_it->end,
+               ret = set_trimmer_iterator_bound(trimmer_it, &trimmer_it->end,
                        ns_from_origin, trimmer_comp->is_gmt);
                if (ret) {
                        goto error;
                }
        }
 
-       ret = validate_trimmer_bounds(&trimmer_it->begin,
-               &trimmer_it->end);
+       ret = validate_trimmer_bounds(trimmer_it->trimmer_comp,
+               &trimmer_it->begin, &trimmer_it->end);
        if (ret) {
                goto error;
        }
@@ -879,6 +887,7 @@ static
 bt_self_message_iterator_status state_seek_initially(
                struct trimmer_iterator *trimmer_it)
 {
+       struct trimmer_comp *trimmer_comp = trimmer_it->trimmer_comp;
        bt_self_message_iterator_status status =
                BT_SELF_MESSAGE_ITERATOR_STATUS_OK;
 
@@ -1664,6 +1673,7 @@ bt_self_message_iterator_status handle_message(
        bool skip;
        int ret;
        struct trimmer_iterator_stream_state *sstate = NULL;
+       struct trimmer_comp *trimmer_comp = trimmer_it->trimmer_comp;
 
        /* Find message's associated stream */
        switch (bt_message_get_type(msg)) {
This page took 0.030058 seconds and 4 git commands to generate.