From 98903a3ed6827edb1228cf8f9f30a6eb1b81bb49 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Wed, 19 Jun 2019 02:14:39 -0400 Subject: [PATCH] src.ctf.fs: honor component's initial log level Signed-off-by: Philippe Proulx Change-Id: I75064d71438939a351748671534efcdf83059192 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1509 Reviewed-by: Francis Deslauriers --- src/cli/babeltrace2.c | 1 - src/plugins/ctf/fs-src/Makefile.am | 4 +- src/plugins/ctf/fs-src/data-stream-file.c | 29 ++++--- src/plugins/ctf/fs-src/data-stream-file.h | 7 +- src/plugins/ctf/fs-src/file.c | 10 ++- src/plugins/ctf/fs-src/file.h | 2 +- src/plugins/ctf/fs-src/fs.c | 95 ++++++++++++++--------- src/plugins/ctf/fs-src/fs.h | 10 ++- src/plugins/ctf/fs-src/logging.c | 26 ------- src/plugins/ctf/fs-src/logging.h | 31 -------- src/plugins/ctf/fs-src/metadata.c | 17 ++-- src/plugins/ctf/fs-src/query.c | 18 ++--- src/plugins/ctf/fs-src/query.h | 6 +- 13 files changed, 121 insertions(+), 135 deletions(-) delete mode 100644 src/plugins/ctf/fs-src/logging.c delete mode 100644 src/plugins/ctf/fs-src/logging.h diff --git a/src/cli/babeltrace2.c b/src/cli/babeltrace2.c index 8c4b18a6..e38eac70 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_SRC_CTF_FS_LOG_LEVEL", NULL, }; diff --git a/src/plugins/ctf/fs-src/Makefile.am b/src/plugins/ctf/fs-src/Makefile.am index 37ad7ed6..f4c2dd97 100644 --- a/src/plugins/ctf/fs-src/Makefile.am +++ b/src/plugins/ctf/fs-src/Makefile.am @@ -11,6 +11,4 @@ libbabeltrace2_plugin_ctf_fs_src_la_SOURCES = \ metadata.c \ metadata.h \ query.h \ - query.c \ - logging.h \ - logging.c + query.c diff --git a/src/plugins/ctf/fs-src/data-stream-file.c b/src/plugins/ctf/fs-src/data-stream-file.c index c3ae979c..69074dbd 100644 --- a/src/plugins/ctf/fs-src/data-stream-file.c +++ b/src/plugins/ctf/fs-src/data-stream-file.c @@ -22,6 +22,10 @@ * SOFTWARE. */ +#define BT_LOG_OUTPUT_LEVEL (ds_file->log_level) +#define BT_LOG_TAG "PLUGIN/SRC.CTF.FS/DS" +#include "logging/log.h" + #include #include #include @@ -40,9 +44,6 @@ #include "data-stream-file.h" #include -#define BT_LOG_TAG "PLUGIN/SRC.CTF.FS/DS" -#include "logging.h" - static inline size_t remaining_mmap_bytes(struct ctf_fs_ds_file *ds_file) { @@ -223,7 +224,7 @@ enum bt_msg_iter_medium_status medop_seek(enum bt_msg_iter_seek_whence whence, offset >= ds_file->mmap_offset + ds_file->mmap_len)) { int unmap_ret; off_t offset_in_mapping = offset % - bt_common_get_page_size(BT_LOG_OUTPUT_LEVEL); + bt_common_get_page_size(ds_file->log_level); BT_LOGD("Medium seek request cannot be accomodated by the current " "file mapping: offset=%jd, mmap-offset=%jd, " @@ -367,7 +368,7 @@ struct ctf_fs_ds_index *build_index_from_idx_file( goto error; } - index = ctf_fs_ds_index_create(); + index = ctf_fs_ds_index_create(ds_file->log_level); if (!index) { goto error; } @@ -513,7 +514,7 @@ struct ctf_fs_ds_index *build_index_from_stream_file( BT_LOGI("Indexing stream file %s", ds_file->file->path->str); - index = ctf_fs_ds_index_create(); + index = ctf_fs_ds_index_create(ds_file->log_level); if (!index) { goto error; } @@ -606,18 +607,20 @@ struct ctf_fs_ds_file *ctf_fs_ds_file_create( struct ctf_fs_trace *ctf_fs_trace, bt_self_message_iterator *pc_msg_iter, struct bt_msg_iter *msg_iter, - bt_stream *stream, const char *path) + bt_stream *stream, const char *path, + bt_logging_level log_level) { int ret; - const size_t page_size = bt_common_get_page_size(BT_LOG_OUTPUT_LEVEL); + const size_t page_size = bt_common_get_page_size(log_level); struct ctf_fs_ds_file *ds_file = g_new0(struct ctf_fs_ds_file, 1); if (!ds_file) { goto error; } + ds_file->log_level = log_level; ds_file->pc_msg_iter = pc_msg_iter; - ds_file->file = ctf_fs_file_create(); + ds_file->file = ctf_fs_file_create(log_level); if (!ds_file->file) { goto error; } @@ -669,18 +672,20 @@ end: } BT_HIDDEN -struct ctf_fs_ds_index *ctf_fs_ds_index_create() +struct ctf_fs_ds_index *ctf_fs_ds_index_create(bt_logging_level log_level) { struct ctf_fs_ds_index *index = g_new0(struct ctf_fs_ds_index, 1); if (!index) { - BT_LOGE_STR("Failed to allocate index"); + BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG, + "Failed to allocate index"); goto error; } index->entries = g_ptr_array_new_with_free_func((GDestroyNotify) g_free); if (!index->entries) { - BT_LOGE("Failed to allocate index entries."); + BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG, + "Failed to allocate index entries."); goto error; } diff --git a/src/plugins/ctf/fs-src/data-stream-file.h b/src/plugins/ctf/fs-src/data-stream-file.h index d3ad00ff..64b5b50b 100644 --- a/src/plugins/ctf/fs-src/data-stream-file.h +++ b/src/plugins/ctf/fs-src/data-stream-file.h @@ -48,6 +48,8 @@ struct ctf_fs_ds_file_info { struct ctf_fs_metadata; struct ctf_fs_ds_file { + bt_logging_level log_level; + /* Weak */ struct ctf_fs_metadata *metadata; @@ -91,7 +93,8 @@ struct ctf_fs_ds_file *ctf_fs_ds_file_create( struct ctf_fs_trace *ctf_fs_trace, bt_self_message_iterator *pc_msg_iter, struct bt_msg_iter *msg_iter, - bt_stream *stream, const char *path); + bt_stream *stream, const char *path, + bt_logging_level log_level); BT_HIDDEN void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *stream); @@ -106,7 +109,7 @@ struct ctf_fs_ds_index *ctf_fs_ds_file_build_index( struct ctf_fs_ds_file *ds_file); BT_HIDDEN -struct ctf_fs_ds_index *ctf_fs_ds_index_create(); +struct ctf_fs_ds_index *ctf_fs_ds_index_create(bt_logging_level log_level); BT_HIDDEN void ctf_fs_ds_index_destroy(struct ctf_fs_ds_index *index); diff --git a/src/plugins/ctf/fs-src/file.c b/src/plugins/ctf/fs-src/file.c index de913a70..c1af7c69 100644 --- a/src/plugins/ctf/fs-src/file.c +++ b/src/plugins/ctf/fs-src/file.c @@ -20,6 +20,10 @@ * SOFTWARE. */ +#define BT_LOG_OUTPUT_LEVEL (file->log_level) +#define BT_LOG_TAG "PLUGIN/SRC.CTF.FS/FILE" +#include "logging/log.h" + #include #include #include @@ -27,9 +31,6 @@ #include #include "file.h" -#define BT_LOG_TAG "PLUGIN/SRC.CTF.FS/FILE" -#include "logging.h" - BT_HIDDEN void ctf_fs_file_destroy(struct ctf_fs_file *file) { @@ -56,7 +57,7 @@ void ctf_fs_file_destroy(struct ctf_fs_file *file) } BT_HIDDEN -struct ctf_fs_file *ctf_fs_file_create(void) +struct ctf_fs_file *ctf_fs_file_create(bt_logging_level log_level) { struct ctf_fs_file *file = g_new0(struct ctf_fs_file, 1); @@ -64,6 +65,7 @@ struct ctf_fs_file *ctf_fs_file_create(void) goto error; } + file->log_level = log_level; file->path = g_string_new(NULL); if (!file->path) { goto error; diff --git a/src/plugins/ctf/fs-src/file.h b/src/plugins/ctf/fs-src/file.h index 78209384..e2845f5c 100644 --- a/src/plugins/ctf/fs-src/file.h +++ b/src/plugins/ctf/fs-src/file.h @@ -32,7 +32,7 @@ BT_HIDDEN void ctf_fs_file_destroy(struct ctf_fs_file *file); BT_HIDDEN -struct ctf_fs_file *ctf_fs_file_create(void); +struct ctf_fs_file *ctf_fs_file_create(bt_logging_level log_level); BT_HIDDEN int ctf_fs_file_open(struct ctf_fs_file *file, const char *mode); diff --git a/src/plugins/ctf/fs-src/fs.c b/src/plugins/ctf/fs-src/fs.c index 37a21f61..1c3f6e1a 100644 --- a/src/plugins/ctf/fs-src/fs.c +++ b/src/plugins/ctf/fs-src/fs.c @@ -25,6 +25,10 @@ * SOFTWARE. */ +#define BT_LOG_OUTPUT_LEVEL log_level +#define BT_LOG_TAG "PLUGIN/SRC.CTF.FS" +#include "logging/log.h" + #include "common/common.h" #include #include "compat/uuid.h" @@ -40,9 +44,6 @@ #include "../common/msg-iter/msg-iter.h" #include "query.h" -#define BT_LOG_TAG "PLUGIN/SRC.CTF.FS" -#include "logging.h" - static int msg_iter_data_set_current_ds_file(struct ctf_fs_msg_iter_data *msg_iter_data) { @@ -61,7 +62,8 @@ int msg_iter_data_set_current_ds_file(struct ctf_fs_msg_iter_data *msg_iter_data msg_iter_data->pc_msg_iter, msg_iter_data->msg_iter, msg_iter_data->ds_file_group->stream, - ds_file_info->path->str); + ds_file_info->path->str, + msg_iter_data->log_level); if (!msg_iter_data->ds_file) { ret = -1; } @@ -245,22 +247,25 @@ bt_self_message_iterator_status ctf_fs_iterator_init( struct ctf_fs_msg_iter_data *msg_iter_data = NULL; bt_self_message_iterator_status ret = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + bt_logging_level log_level; port_data = bt_self_component_port_get_data( bt_self_component_port_output_as_self_component_port( self_port)); BT_ASSERT(port_data); + log_level = port_data->ctf_fs->log_level; msg_iter_data = g_new0(struct ctf_fs_msg_iter_data, 1); if (!msg_iter_data) { ret = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; goto error; } + msg_iter_data->log_level = log_level; msg_iter_data->pc_msg_iter = self_msg_iter; 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, BT_LOG_OUTPUT_LEVEL, NULL); + bt_common_get_page_size(msg_iter_data->log_level) * 8, + ctf_fs_ds_file_medops, NULL, msg_iter_data->log_level, NULL); if (!msg_iter_data->msg_iter) { BT_LOGE_STR("Cannot create a CTF message iterator."); ret = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; @@ -359,7 +364,7 @@ void ctf_fs_trace_destroy_notifier(void *data) ctf_fs_trace_destroy(trace); } -struct ctf_fs_component *ctf_fs_component_create(void) +struct ctf_fs_component *ctf_fs_component_create(bt_logging_level log_level) { struct ctf_fs_component *ctf_fs; @@ -368,6 +373,7 @@ struct ctf_fs_component *ctf_fs_component_create(void) goto error; } + ctf_fs->log_level = log_level; ctf_fs->port_data = g_ptr_array_new_with_free_func(port_data_destroy_notifier); if (!ctf_fs->port_data) { @@ -449,6 +455,7 @@ int create_one_port_for_trace(struct ctf_fs_component *ctf_fs, int ret = 0; struct ctf_fs_port_data *port_data = NULL; gchar *port_name; + bt_logging_level log_level = ctf_fs->log_level; port_name = ctf_fs_make_port_name(ds_file_group); if (!port_name) { @@ -493,6 +500,7 @@ int create_ports_for_trace(struct ctf_fs_component *ctf_fs, { int ret = 0; size_t i; + bt_logging_level log_level = ctf_fs_trace->log_level; /* Create one output port for each stream file group */ for (i = 0; i < ctf_fs_trace->ds_file_groups->len; i++) { @@ -718,17 +726,18 @@ int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, struct bt_msg_iter *msg_iter = NULL; struct ctf_stream_class *sc = NULL; struct bt_msg_iter_packet_properties props; + bt_logging_level log_level = ctf_fs_trace->log_level; 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, BT_LOG_OUTPUT_LEVEL, NULL); + bt_common_get_page_size(log_level) * 8, + ctf_fs_ds_file_medops, NULL, log_level, NULL); if (!msg_iter) { BT_LOGE_STR("Cannot create a CTF message iterator."); goto error; } ds_file = ctf_fs_ds_file_create(ctf_fs_trace, NULL, msg_iter, - NULL, path); + NULL, path, log_level); if (!ds_file) { goto error; } @@ -865,6 +874,7 @@ int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace) const char *basename; GError *error = NULL; GDir *dir = NULL; + bt_logging_level log_level = ctf_fs_trace->log_level; /* Check each file in the path directory, except specific ones */ dir = g_dir_open(ctf_fs_trace->path->str, 0, &error); @@ -892,7 +902,7 @@ int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace) } /* Create the file. */ - file = ctf_fs_file_create(); + file = ctf_fs_file_create(log_level); if (!file) { BT_LOGE("Cannot create stream file object for file `%s" G_DIR_SEPARATOR_S "%s`", ctf_fs_trace->path->str, basename); @@ -954,7 +964,8 @@ end: } static -int set_trace_name(bt_trace *trace, const char *name_suffix) +int set_trace_name(bt_trace *trace, const char *name_suffix, + bt_logging_level log_level) { int ret = 0; const bt_trace_class *tc = bt_trace_borrow_class_const(trace); @@ -1004,7 +1015,8 @@ end: static struct ctf_fs_trace *ctf_fs_trace_create(bt_self_component_source *self_comp, const char *path, const char *name, - struct ctf_fs_metadata_config *metadata_config) + struct ctf_fs_metadata_config *metadata_config, + bt_logging_level log_level) { struct ctf_fs_trace *ctf_fs_trace; int ret; @@ -1014,6 +1026,7 @@ struct ctf_fs_trace *ctf_fs_trace_create(bt_self_component_source *self_comp, goto end; } + ctf_fs_trace->log_level = log_level; ctf_fs_trace->path = g_string_new(path); if (!ctf_fs_trace->path) { goto error; @@ -1051,7 +1064,7 @@ struct ctf_fs_trace *ctf_fs_trace_create(bt_self_component_source *self_comp, } if (ctf_fs_trace->trace) { - ret = set_trace_name(ctf_fs_trace->trace, name); + ret = set_trace_name(ctf_fs_trace->trace, name, log_level); if (ret) { goto error; } @@ -1096,7 +1109,8 @@ end: } static -int add_trace_path(GList **trace_paths, const char *path) +int add_trace_path(GList **trace_paths, const char *path, + bt_logging_level log_level) { GString *norm_path = NULL; int ret = 0; @@ -1128,7 +1142,8 @@ end: } static -int ctf_fs_find_traces(GList **trace_paths, const char *start_path) +int ctf_fs_find_traces(GList **trace_paths, const char *start_path, + bt_logging_level log_level) { int ret; GError *error = NULL; @@ -1146,7 +1161,7 @@ int ctf_fs_find_traces(GList **trace_paths, const char *start_path) * Stop recursion: a CTF trace cannot contain another * CTF trace. */ - ret = add_trace_path(trace_paths, start_path); + ret = add_trace_path(trace_paths, start_path, log_level); goto end; } @@ -1179,7 +1194,8 @@ int ctf_fs_find_traces(GList **trace_paths, const char *start_path) } g_string_printf(sub_path, "%s" G_DIR_SEPARATOR_S "%s", start_path, basename); - ret = ctf_fs_find_traces(trace_paths, sub_path->str); + ret = ctf_fs_find_traces(trace_paths, sub_path->str, + log_level); g_string_free(sub_path, TRUE); if (ret) { goto end; @@ -1265,6 +1281,7 @@ int ctf_fs_component_create_ctf_fs_traces_one_root(bt_self_component_source *sel GList *trace_names = NULL; GList *tp_node; GList *tn_node; + bt_logging_level log_level = ctf_fs->log_level; norm_path = bt_common_normalize_path(path_param, NULL); if (!norm_path) { @@ -1273,7 +1290,7 @@ int ctf_fs_component_create_ctf_fs_traces_one_root(bt_self_component_source *sel goto error; } - ret = ctf_fs_find_traces(&trace_paths, norm_path->str); + ret = ctf_fs_find_traces(&trace_paths, norm_path->str, log_level); if (ret) { goto error; } @@ -1298,7 +1315,8 @@ int ctf_fs_component_create_ctf_fs_traces_one_root(bt_self_component_source *sel ctf_fs_trace = ctf_fs_trace_create(self_comp, trace_path->str, trace_name->str, - &ctf_fs->metadata_config); + &ctf_fs->metadata_config, + log_level); if (!ctf_fs_trace) { BT_LOGE("Cannot create trace for `%s`.", trace_path->str); @@ -1492,7 +1510,7 @@ int merge_matching_ctf_fs_ds_file_groups( dest_trace->metadata->tc, src_group->sc->id); BT_ASSERT(sc); - index = ctf_fs_ds_index_create(); + index = ctf_fs_ds_index_create(dest_trace->log_level); if (!index) { ret = -1; goto end; @@ -1709,6 +1727,7 @@ int create_streams_for_trace(struct ctf_fs_trace *ctf_fs_trace) int ret; GString *name = NULL; guint i; + bt_logging_level log_level = ctf_fs_trace->log_level; for (i = 0; i < ctf_fs_trace->ds_file_groups->len; i++) { struct ctf_fs_ds_file_group *ds_file_group = @@ -1780,11 +1799,13 @@ end: */ static -bool validate_paths_parameter(const bt_value *paths) +bool validate_paths_parameter(struct ctf_fs_component *ctf_fs, + const bt_value *paths) { bool ret; bt_value_type type; uint64_t i; + bt_logging_level log_level = ctf_fs->log_level; if (!paths) { BT_LOGE("missing \"paths\" parameter"); @@ -1824,10 +1845,11 @@ bool read_src_fs_parameters(const bt_value *params, const bt_value **paths, struct ctf_fs_component *ctf_fs) { bool ret; const bt_value *value; + bt_logging_level log_level = ctf_fs->log_level; /* paths parameter */ *paths = bt_value_map_borrow_entry_value_const(params, "paths"); - if (!validate_paths_parameter(*paths)) { + if (!validate_paths_parameter(ctf_fs, *paths)) { goto error; } @@ -1868,14 +1890,17 @@ end: static struct ctf_fs_component *ctf_fs_create( - bt_self_component_source *self_comp, + bt_self_component_source *self_comp_src, const bt_value *params) { struct ctf_fs_component *ctf_fs = NULL; guint i; const bt_value *paths_value; + bt_self_component *self_comp = + bt_self_component_source_as_self_component(self_comp_src); - ctf_fs = ctf_fs_component_create(); + ctf_fs = ctf_fs_component_create(bt_component_get_logging_level( + bt_self_component_as_component(self_comp))); if (!ctf_fs) { goto error; } @@ -1884,18 +1909,16 @@ struct ctf_fs_component *ctf_fs_create( goto error; } - bt_self_component_set_data( - bt_self_component_source_as_self_component(self_comp), - ctf_fs); + bt_self_component_set_data(self_comp, ctf_fs); /* * We don't need to get a new reference here because as long as * our private ctf_fs_component object exists, the containing * private component should also exist. */ - ctf_fs->self_comp = self_comp; + ctf_fs->self_comp = self_comp_src; - if (ctf_fs_component_create_ctf_fs_traces(self_comp, ctf_fs, paths_value)) { + if (ctf_fs_component_create_ctf_fs_traces(self_comp_src, ctf_fs, paths_value)) { goto error; } @@ -1916,9 +1939,7 @@ struct ctf_fs_component *ctf_fs_create( error: ctf_fs_destroy(ctf_fs); ctf_fs = NULL; - bt_self_component_set_data( - bt_self_component_source_as_self_component(self_comp), - NULL); + bt_self_component_set_data(self_comp, NULL); end: return ctf_fs; @@ -1945,15 +1966,17 @@ bt_query_status ctf_fs_query( bt_self_component_class_source *comp_class, const bt_query_executor *query_exec, const char *object, const bt_value *params, - __attribute__((unused)) bt_logging_level log_level, + bt_logging_level log_level, const bt_value **result) { bt_query_status status = BT_QUERY_STATUS_OK; if (!strcmp(object, "metadata-info")) { - status = metadata_info_query(comp_class, params, result); + status = metadata_info_query(comp_class, params, log_level, + result); } else if (!strcmp(object, "trace-info")) { - status = trace_info_query(comp_class, params, result); + status = trace_info_query(comp_class, params, log_level, + result); } else { BT_LOGE("Unknown query object `%s`", object); status = BT_QUERY_STATUS_INVALID_OBJECT; diff --git a/src/plugins/ctf/fs-src/fs.h b/src/plugins/ctf/fs-src/fs.h index 7ab98adc..d4dec888 100644 --- a/src/plugins/ctf/fs-src/fs.h +++ b/src/plugins/ctf/fs-src/fs.h @@ -39,6 +39,8 @@ BT_HIDDEN extern bool ctf_fs_debug; struct ctf_fs_file { + bt_logging_level log_level; + /* Owned by this */ GString *path; @@ -67,6 +69,8 @@ struct ctf_fs_metadata { }; struct ctf_fs_component { + bt_logging_level log_level; + /* Weak, guaranteed to exist */ bt_self_component_source *self_comp; @@ -80,6 +84,8 @@ struct ctf_fs_component { }; struct ctf_fs_trace { + bt_logging_level log_level; + /* Owned by this */ struct ctf_fs_metadata *metadata; @@ -168,6 +174,8 @@ struct ctf_fs_port_data { }; struct ctf_fs_msg_iter_data { + bt_logging_level log_level; + /* Weak */ bt_self_message_iterator *pc_msg_iter; @@ -222,7 +230,7 @@ bt_self_message_iterator_status ctf_fs_iterator_seek_beginning( /* Create and initialize a new, empty ctf_fs_component. */ BT_HIDDEN -struct ctf_fs_component *ctf_fs_component_create(void); +struct ctf_fs_component *ctf_fs_component_create(bt_logging_level log_level); /* * Search recursively under all paths in `paths_value` (an array of strings), diff --git a/src/plugins/ctf/fs-src/logging.c b/src/plugins/ctf/fs-src/logging.c deleted file mode 100644 index e9e58629..00000000 --- a/src/plugins/ctf/fs-src/logging.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2017 Jérémie Galarneau - * - * 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_fs_src_log_level -#include "logging/log.h" - -BT_LOG_INIT_LOG_LEVEL(BT_LOG_OUTPUT_LEVEL, "BABELTRACE_SRC_CTF_FS_LOG_LEVEL"); diff --git a/src/plugins/ctf/fs-src/logging.h b/src/plugins/ctf/fs-src/logging.h deleted file mode 100644 index 2f52057b..00000000 --- a/src/plugins/ctf/fs-src/logging.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2017 Jérémie Galarneau - * - * 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. - */ - -#ifndef CTF_FS_SRC_LOGGING_H -#define CTF_FS_SRC_LOGGING_H - -#define BT_LOG_OUTPUT_LEVEL ctf_fs_src_log_level -#include "logging/log.h" - -BT_LOG_LEVEL_EXTERN_SYMBOL(ctf_fs_src_log_level); - -#endif /* CTF_FS_SRC_LOGGING_H */ diff --git a/src/plugins/ctf/fs-src/metadata.c b/src/plugins/ctf/fs-src/metadata.c index 16463292..403ed03d 100644 --- a/src/plugins/ctf/fs-src/metadata.c +++ b/src/plugins/ctf/fs-src/metadata.c @@ -23,6 +23,10 @@ * SOFTWARE. */ +#define BT_LOG_OUTPUT_LEVEL log_level +#define BT_LOG_TAG "PLUGIN/SRC.CTF.FS/META" +#include "logging/log.h" + #include #include #include @@ -38,9 +42,6 @@ #include "metadata.h" #include "../common/metadata/decoder.h" -#define BT_LOG_TAG "PLUGIN/SRC.CTF.FS/META" -#include "logging.h" - BT_HIDDEN FILE *ctf_fs_metadata_open_file(const char *trace_path) { @@ -59,9 +60,10 @@ end: return fp; } -static struct ctf_fs_file *get_file(const char *trace_path) +static struct ctf_fs_file *get_file(const char *trace_path, + bt_logging_level log_level) { - struct ctf_fs_file *file = ctf_fs_file_create(); + struct ctf_fs_file *file = ctf_fs_file_create(log_level); if (!file) { goto error; @@ -95,13 +97,14 @@ int ctf_fs_metadata_set_trace_class( int ret = 0; struct ctf_fs_file *file = NULL; struct ctf_metadata_decoder_config decoder_config = { - .log_level = BT_LOG_OUTPUT_LEVEL, + .log_level = ctf_fs_trace->log_level, .self_comp = bt_self_component_source_as_self_component(self_comp), .clock_class_offset_s = config ? config->clock_class_offset_s : 0, .clock_class_offset_ns = config ? config->clock_class_offset_ns : 0, }; + bt_logging_level log_level = ctf_fs_trace->log_level; - file = get_file(ctf_fs_trace->path->str); + file = get_file(ctf_fs_trace->path->str, log_level); if (!file) { BT_LOGE("Cannot create metadata file object"); ret = -1; diff --git a/src/plugins/ctf/fs-src/query.c b/src/plugins/ctf/fs-src/query.c index 5df82599..6f78505b 100644 --- a/src/plugins/ctf/fs-src/query.c +++ b/src/plugins/ctf/fs-src/query.c @@ -24,6 +24,10 @@ * SOFTWARE. */ +#define BT_LOG_OUTPUT_LEVEL log_level +#define BT_LOG_TAG "PLUGIN/SRC.CTF.FS/QUERY" +#include "logging/log.h" + #include "query.h" #include #include "common/assert.h" @@ -34,9 +38,6 @@ #include #include "fs.h" -#define BT_LOG_TAG "PLUGIN/SRC.CTF.FS/QUERY" -#include "logging.h" - #define METADATA_TEXT_SIG "/* CTF 1.8" struct range { @@ -48,7 +49,7 @@ struct range { BT_HIDDEN bt_query_status metadata_info_query( bt_self_component_class_source *comp_class, - const bt_value *params, + const bt_value *params, bt_logging_level log_level, const bt_value **user_result) { bt_query_status status = BT_QUERY_STATUS_OK; @@ -99,12 +100,11 @@ bt_query_status metadata_info_query( } is_packetized = ctf_metadata_decoder_is_packetized(metadata_fp, - &bo, BT_LOG_OUTPUT_LEVEL, NULL); + &bo, log_level, NULL); if (is_packetized) { ret = ctf_metadata_decoder_packetized_file_stream_to_buf( - metadata_fp, &metadata_text, bo, - BT_LOG_OUTPUT_LEVEL, NULL); + metadata_fp, &metadata_text, bo, log_level, NULL); if (ret) { BT_LOGE("Cannot decode packetized metadata file: path=\"%s\"", path); @@ -471,7 +471,7 @@ end: BT_HIDDEN bt_query_status trace_info_query( bt_self_component_class_source *comp_class, - const bt_value *params, + const bt_value *params, bt_logging_level log_level, const bt_value **user_result) { struct ctf_fs_component *ctf_fs = NULL; @@ -489,7 +489,7 @@ bt_query_status trace_info_query( goto error; } - ctf_fs = ctf_fs_component_create(); + ctf_fs = ctf_fs_component_create(log_level); if (!ctf_fs) { goto error; } diff --git a/src/plugins/ctf/fs-src/query.h b/src/plugins/ctf/fs-src/query.h index 35ee4b6c..89e31838 100644 --- a/src/plugins/ctf/fs-src/query.h +++ b/src/plugins/ctf/fs-src/query.h @@ -31,11 +31,13 @@ BT_HIDDEN bt_query_status metadata_info_query( bt_self_component_class_source *comp_class, - const bt_value *params, const bt_value **result); + const bt_value *params, + bt_logging_level log_level, const bt_value **result); BT_HIDDEN bt_query_status trace_info_query( bt_self_component_class_source *comp_class, - const bt_value *params, const bt_value **result); + const bt_value *params, bt_logging_level log_level, + const bt_value **result); #endif /* BABELTRACE_PLUGIN_CTF_FS_QUERY_H */ -- 2.34.1