*/
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",
libctf_msg_iter_la_SOURCES = \
msg-iter.c \
- msg-iter.h \
- logging.c \
- logging.h
+ msg-iter.h
+++ /dev/null
-/*
- * 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");
+++ /dev/null
-#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 */
* 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>
size_t index;
};
+struct bt_msg_iter;
+
/* Visit stack */
struct stack {
+ struct bt_msg_iter *notit;
+
/* Entries (struct stack_entry) */
GArray *entries;
/* Stored values (for sequence lengths, variant tags) */
GArray *stored_values;
+
+ /* Iterator's current log level */
+ bt_logging_level log_level;
};
static inline
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.");
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) {
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",
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);
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 = {
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;
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;
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:
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.
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;
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;
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;
}
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;
}