`ctf` plugin: `bt_msg_iter`: use object's log level
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 17 Jun 2019 22:13:54 +0000 (18:13 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 20 Jun 2019 18:01:16 +0000 (14:01 -0400)
As of this patch, the users of `bt_msg_iter` set the new log level
parameter to their own (global) log level.

The goal is to eventually have a per-component log level for the `ctf`
plugin's component classes.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I279d22831c5857dc10622e6cabacf64c32fa5ed4
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1488
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
src/cli/babeltrace2.c
src/plugins/ctf/common/msg-iter/Makefile.am
src/plugins/ctf/common/msg-iter/logging.c [deleted file]
src/plugins/ctf/common/msg-iter/logging.h [deleted file]
src/plugins/ctf/common/msg-iter/msg-iter.c
src/plugins/ctf/common/msg-iter/msg-iter.h
src/plugins/ctf/fs-src/fs.c
src/plugins/ctf/lttng-live/data-stream.c

index 5cd3fd4357e9db51b158d92a8cfffffcc965f9b8..830ebf5ae60501f2d54b14dde56a1667eb9719e3 100644 (file)
@@ -50,7 +50,6 @@
  */
 static const char* log_level_env_var_names[] = {
        "BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL",
-       "BABELTRACE_PLUGIN_CTF_MSG_ITER_LOG_LEVEL",
        "BABELTRACE_PLUGIN_CTF_UTILS_LOG_LEVEL",
        "BABELTRACE_PYTHON_BT2_LOG_LEVEL",
        "BABELTRACE_SINK_CTF_FS_LOG_LEVEL",
index 7c3c2087558e672be67b9dc540640aac2390f41d..e1a00ad988ec1335567c5fbb456abd8ba7a4111f 100644 (file)
@@ -2,6 +2,4 @@ noinst_LTLIBRARIES = libctf-msg-iter.la
 
 libctf_msg_iter_la_SOURCES = \
        msg-iter.c \
-       msg-iter.h \
-       logging.c \
-       logging.h
+       msg-iter.h
diff --git a/src/plugins/ctf/common/msg-iter/logging.c b/src/plugins/ctf/common/msg-iter/logging.c
deleted file mode 100644 (file)
index 662c443..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 ctf_msg_iter_log_level
-#include "logging/log.h"
-
-BT_LOG_INIT_LOG_LEVEL(ctf_msg_iter_log_level,
-       "BABELTRACE_PLUGIN_CTF_MSG_ITER_LOG_LEVEL");
diff --git a/src/plugins/ctf/common/msg-iter/logging.h b/src/plugins/ctf/common/msg-iter/logging.h
deleted file mode 100644 (file)
index 9788916..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef CTF_MSG_ITER_LOGGING_H
-#define CTF_MSG_ITER_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 ctf_msg_iter_log_level
-#include "logging/log.h"
-
-BT_LOG_LEVEL_EXTERN_SYMBOL(ctf_msg_iter_log_level);
-
-#endif /* CTF_MSG_ITER_LOGGING_H */
index 99c585980bf8db9b97f151c3921676613ab1b9be..60d83e151826b230323d73b26fda2aa6fb616c5b 100644 (file)
@@ -23,8 +23,9 @@
  * SOFTWARE.
  */
 
+#define BT_LOG_OUTPUT_LEVEL (notit->log_level)
 #define BT_LOG_TAG "PLUGIN/CTF/MSG-ITER"
-#include "logging.h"
+#include "logging/log.h"
 
 #include <stdint.h>
 #include <inttypes.h>
@@ -62,8 +63,12 @@ struct stack_entry {
        size_t index;
 };
 
+struct bt_msg_iter;
+
 /* Visit stack */
 struct stack {
+       struct bt_msg_iter *notit;
+
        /* Entries (struct stack_entry) */
        GArray *entries;
 
@@ -244,6 +249,9 @@ struct bt_msg_iter {
 
        /* Stored values (for sequence lengths, variant tags) */
        GArray *stored_values;
+
+       /* Iterator's current log level */
+       bt_logging_level log_level;
 };
 
 static inline
@@ -325,6 +333,7 @@ struct stack *stack_new(struct bt_msg_iter *notit)
                goto error;
        }
 
+       stack->notit = notit;
        stack->entries = g_array_new(FALSE, TRUE, sizeof(struct stack_entry));
        if (!stack->entries) {
                BT_LOGE_STR("Failed to allocate a GArray.");
@@ -345,7 +354,10 @@ end:
 static
 void stack_destroy(struct stack *stack)
 {
+       struct bt_msg_iter *notit;
+
        BT_ASSERT(stack);
+       notit = stack->notit;
        BT_LOGD("Destroying stack: addr=%p", stack);
 
        if (stack->entries) {
@@ -359,8 +371,10 @@ static
 void stack_push(struct stack *stack, bt_field *base)
 {
        struct stack_entry *entry;
+       struct bt_msg_iter *notit;
 
        BT_ASSERT(stack);
+       notit = stack->notit;
        BT_ASSERT(base);
        BT_LOGV("Pushing base field on stack: stack-addr=%p, "
                "stack-size-before=%zu, stack-size-after=%zu",
@@ -386,8 +400,11 @@ unsigned int stack_size(struct stack *stack)
 static
 void stack_pop(struct stack *stack)
 {
+       struct bt_msg_iter *notit;
+
        BT_ASSERT(stack);
        BT_ASSERT(stack_size(stack));
+       notit = stack->notit;
        BT_LOGV("Popping from stack: "
                "stack-addr=%p, stack-size-before=%zu, stack-size-after=%zu",
                stack, stack->size, stack->size - 1);
@@ -2683,7 +2700,8 @@ void create_msg_discarded_packets(struct bt_msg_iter *notit,
 BT_HIDDEN
 struct bt_msg_iter *bt_msg_iter_create(struct ctf_trace_class *tc,
                size_t max_request_sz,
-               struct bt_msg_iter_medium_ops medops, void *data)
+               struct bt_msg_iter_medium_ops medops, void *data,
+               bt_logging_level log_level)
 {
        struct bt_msg_iter *notit = NULL;
        struct bt_bfcr_cbs cbs = {
@@ -2706,14 +2724,18 @@ struct bt_msg_iter *bt_msg_iter_create(struct ctf_trace_class *tc,
        BT_ASSERT(tc);
        BT_ASSERT(medops.request_bytes);
        BT_ASSERT(medops.borrow_stream);
-       BT_LOGD("Creating CTF plugin message iterator: "
+       BT_LOG_WRITE_CUR_LVL(BT_LOG_DEBUG, log_level, BT_LOG_TAG,
+               "Creating CTF plugin message iterator: "
                "trace-addr=%p, max-request-size=%zu, "
-               "data=%p", tc, max_request_sz, data);
+               "data=%p, log-level=%s", tc, max_request_sz, data,
+               bt_common_logging_level_string(log_level));
        notit = g_new0(struct bt_msg_iter, 1);
        if (!notit) {
-               BT_LOGE_STR("Failed to allocate one CTF plugin message iterator.");
+               BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG,
+                       "Failed to allocate one CTF plugin message iterator.");
                goto end;
        }
+       notit->log_level = log_level;
        notit->meta.tc = tc;
        notit->medium.medops = medops;
        notit->medium.max_request_sz = max_request_sz;
@@ -2727,7 +2749,7 @@ struct bt_msg_iter *bt_msg_iter_create(struct ctf_trace_class *tc,
                goto error;
        }
 
-       notit->bfcr = bt_bfcr_create(cbs, notit, BT_LOG_OUTPUT_LEVEL);
+       notit->bfcr = bt_bfcr_create(cbs, notit, log_level);
        if (!notit->bfcr) {
                BT_LOGE_STR("Failed to create binary class reader (BFCR).");
                goto error;
@@ -2736,8 +2758,9 @@ struct bt_msg_iter *bt_msg_iter_create(struct ctf_trace_class *tc,
        bt_msg_iter_reset(notit);
        BT_LOGD("Created CTF plugin message iterator: "
                "trace-addr=%p, max-request-size=%zu, "
-               "data=%p, notit-addr=%p",
-               tc, max_request_sz, data, notit);
+               "data=%p, notit-addr=%p, log-level=%s",
+               tc, max_request_sz, data, notit,
+               bt_common_logging_level_string(log_level));
        notit->cur_packet_offset = 0;
 
 end:
index 77849db691ab01ff40d8b98e282060c463c7c8d5..1aeeafe5e91969c33bd38981d8cde57ddda7b5eb 100644 (file)
@@ -253,7 +253,7 @@ struct bt_msg_iter;
 BT_HIDDEN
 struct bt_msg_iter *bt_msg_iter_create(struct ctf_trace_class *tc,
        size_t max_request_sz, struct bt_msg_iter_medium_ops medops,
-       void *medops_data);
+       void *medops_data, bt_logging_level log_level);
 
 /**
  * Destroys a CTF message iterator, freeing all internal resources.
index dc94e95b5547486b2d7f4850106d200e9276b1e3..7ea06e13da7b53886f5c494c4e0241c3d121fcf6 100644 (file)
@@ -261,7 +261,7 @@ bt_self_message_iterator_status ctf_fs_iterator_init(
        msg_iter_data->msg_iter = bt_msg_iter_create(
                port_data->ds_file_group->ctf_fs_trace->metadata->tc,
                bt_common_get_page_size(BT_LOG_OUTPUT_LEVEL) * 8,
-               ctf_fs_ds_file_medops, NULL);
+               ctf_fs_ds_file_medops, NULL, BT_LOG_OUTPUT_LEVEL);
        if (!msg_iter_data->msg_iter) {
                BT_LOGE_STR("Cannot create a CTF message iterator.");
                ret = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM;
@@ -722,7 +722,7 @@ int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace,
 
        msg_iter = bt_msg_iter_create(ctf_fs_trace->metadata->tc,
                bt_common_get_page_size(BT_LOG_OUTPUT_LEVEL) * 8,
-               ctf_fs_ds_file_medops, NULL);
+               ctf_fs_ds_file_medops, NULL, BT_LOG_OUTPUT_LEVEL);
        if (!msg_iter) {
                BT_LOGE_STR("Cannot create a CTF message iterator.");
                goto error;
index 5641d281ee75c74300b265d528e7fc585355943c..7d3abaae5942b6d83dae91b1f42960b4ffc611fa 100644 (file)
@@ -152,7 +152,7 @@ enum lttng_live_iterator_status lttng_live_lazy_msg_init(
                                                trace->metadata->decoder);
                        stream_iter->msg_iter = bt_msg_iter_create(ctf_tc,
                                        lttng_live->max_query_size, medops,
-                                       stream_iter);
+                                       stream_iter, BT_LOG_OUTPUT_LEVEL);
                        if (!stream_iter->msg_iter) {
                                goto error;
                        }
@@ -206,7 +206,7 @@ struct lttng_live_stream_iterator *lttng_live_stream_iterator_create(
                BT_ASSERT(!stream_iter->msg_iter);
                stream_iter->msg_iter = bt_msg_iter_create(ctf_tc,
                                lttng_live->max_query_size, medops,
-                               stream_iter);
+                               stream_iter, BT_LOG_OUTPUT_LEVEL);
                if (!stream_iter->msg_iter) {
                        goto error;
                }
This page took 0.03011 seconds and 4 git commands to generate.