From: Philippe Proulx Date: Tue, 18 Jun 2019 18:48:54 +0000 (-0400) Subject: sink.text.details: honor component's initial log level X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=6c868a3a0167202c6a5d2ecae8bbb78a17b7e6ae sink.text.details: honor component's initial log level Signed-off-by: Philippe Proulx Change-Id: If24cf10be949c4e637b4677b9780c00a58e14df2 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1500 Reviewed-by: Francis Deslauriers --- diff --git a/src/cli/babeltrace2.c b/src/cli/babeltrace2.c index d3cabdc9..8c4b18a6 100644 --- a/src/cli/babeltrace2.c +++ b/src/cli/babeltrace2.c @@ -51,7 +51,6 @@ static const char* log_level_env_var_names[] = { "BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL", "BABELTRACE_PYTHON_BT2_LOG_LEVEL", - "BABELTRACE_SINK_TEXT_DETAILS_LOG_LEVEL", "BABELTRACE_SRC_CTF_FS_LOG_LEVEL", NULL, }; diff --git a/src/plugins/text/details/Makefile.am b/src/plugins/text/details/Makefile.am index fefae102..7b230478 100644 --- a/src/plugins/text/details/Makefile.am +++ b/src/plugins/text/details/Makefile.am @@ -5,5 +5,4 @@ libbabeltrace2_plugin_text_details_cc_la_SOURCES = \ details.c details.h \ write.c write.h \ obj-lifetime-mgmt.c obj-lifetime-mgmt.h \ - colors.h \ - logging.c logging.h + colors.h diff --git a/src/plugins/text/details/details.c b/src/plugins/text/details/details.c index 8f09efa4..8c1f66e3 100644 --- a/src/plugins/text/details/details.c +++ b/src/plugins/text/details/details.c @@ -20,8 +20,9 @@ * SOFTWARE. */ +#define BT_LOG_OUTPUT_LEVEL (details_comp->log_level) #define BT_LOG_TAG "PLUGIN/SINK.TEXT.DETAILS" -#include "logging.h" +#include "logging/log.h" #include @@ -181,14 +182,19 @@ end: } static -struct details_comp *create_details_comp(void) +struct details_comp *create_details_comp( + bt_self_component_sink *self_comp_sink) { struct details_comp *details_comp = g_new0(struct details_comp, 1); + bt_self_component *self_comp = + bt_self_component_sink_as_self_component(self_comp_sink); if (!details_comp) { goto error; } + details_comp->log_level = bt_component_get_logging_level( + bt_self_component_as_component(self_comp)); details_comp->meta = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) details_destroy_details_trace_class_meta); @@ -392,7 +398,7 @@ bt_self_component_status details_init(bt_self_component_sink *comp, goto error; } - details_comp = create_details_comp(); + details_comp = create_details_comp(comp); if (!details_comp) { status = BT_SELF_COMPONENT_STATUS_NOMEM; goto error; diff --git a/src/plugins/text/details/details.h b/src/plugins/text/details/details.h index 41f6acfb..52a28cde 100644 --- a/src/plugins/text/details/details.h +++ b/src/plugins/text/details/details.h @@ -74,6 +74,8 @@ struct details_trace { /* A `sink.text.details` component */ struct details_comp { + bt_logging_level log_level; + /* Component's configuration */ struct { /* Write metadata objects */ diff --git a/src/plugins/text/details/logging.c b/src/plugins/text/details/logging.c deleted file mode 100644 index 6198267c..00000000 --- a/src/plugins/text/details/logging.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2019 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_text_details_log_level -#include "logging/log.h" - -BT_LOG_INIT_LOG_LEVEL(bt_plugin_text_details_log_level, - "BABELTRACE_SINK_TEXT_DETAILS_LOG_LEVEL"); diff --git a/src/plugins/text/details/logging.h b/src/plugins/text/details/logging.h deleted file mode 100644 index 6c881b27..00000000 --- a/src/plugins/text/details/logging.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef BABELTRACE_PLUGINS_TEXT_DETAILS_LOGGING_H -#define BABELTRACE_PLUGINS_TEXT_DETAILS_LOGGING_H - -/* - * Copyright (c) 2019 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_text_details_log_level -#include "logging/log.h" - -BT_LOG_LEVEL_EXTERN_SYMBOL(bt_plugin_text_details_log_level); - -#endif /* BABELTRACE_PLUGINS_TEXT_DETAILS_LOGGING_H */