src.ctf.fs: honor component's initial log level
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 19 Jun 2019 06:14:39 +0000 (02:14 -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: I75064d71438939a351748671534efcdf83059192
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1509
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
13 files changed:
src/cli/babeltrace2.c
src/plugins/ctf/fs-src/Makefile.am
src/plugins/ctf/fs-src/data-stream-file.c
src/plugins/ctf/fs-src/data-stream-file.h
src/plugins/ctf/fs-src/file.c
src/plugins/ctf/fs-src/file.h
src/plugins/ctf/fs-src/fs.c
src/plugins/ctf/fs-src/fs.h
src/plugins/ctf/fs-src/logging.c [deleted file]
src/plugins/ctf/fs-src/logging.h [deleted file]
src/plugins/ctf/fs-src/metadata.c
src/plugins/ctf/fs-src/query.c
src/plugins/ctf/fs-src/query.h

index 8c4b18a6f0b8121766fbcde97db4ad9c9cb1ee9b..e38eac7011150e7c9e1bdda7b4a4e75e305a0d2c 100644 (file)
@@ -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,
 };
 
index 37ad7ed6ba76ffcd6854259947be145d1bcc11cf..f4c2dd9747b1696241bec12ad671f7427bebb938 100644 (file)
@@ -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
index c3ae979c53e67b3364b2d23ce3497ed173ac1fae..69074dbdba10b3bec3862e854bef66fda5fb0d72 100644 (file)
  * SOFTWARE.
  */
 
+#define BT_LOG_OUTPUT_LEVEL (ds_file->log_level)
+#define BT_LOG_TAG "PLUGIN/SRC.CTF.FS/DS"
+#include "logging/log.h"
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdint.h>
@@ -40,9 +44,6 @@
 #include "data-stream-file.h"
 #include <string.h>
 
-#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;
        }
 
index d3ad00ffaca3d8e10f6f630d3a91ee7f5f207536..64b5b50bfc542d8fed8ad9d2cfa71dce7c69b145 100644 (file)
@@ -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);
index de913a70c15c28931d2e4cda76f0c751ca1ef958..c1af7c6926ede5bcfeb6aaa3bf1325681dbf1cbc 100644 (file)
  * SOFTWARE.
  */
 
+#define BT_LOG_OUTPUT_LEVEL (file->log_level)
+#define BT_LOG_TAG "PLUGIN/SRC.CTF.FS/FILE"
+#include "logging/log.h"
+
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -27,9 +31,6 @@
 #include <glib.h>
 #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;
index 78209384d4648b9bd706a56baab42c0ef5b4aa5d..e2845f5c651007545fb65bba14af3661ab1f056a 100644 (file)
@@ -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);
index 37a21f61ee1b83950f5492670a5861ee6870dbbb..1c3f6e1a65762047316af917c1a4003cff8ddc4f 100644 (file)
  * 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 <babeltrace2/babeltrace.h>
 #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;
index 7ab98adc4e2f328979885a62d6bd11572b97dc47..d4dec888933aae08cfc722c8bb7ad2033f88cfc6 100644 (file)
@@ -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 (file)
index e9e5862..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2017 Jérémie Galarneau <jeremie.galarneau@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_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 (file)
index 2f52057..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2017 Jérémie Galarneau <jeremie.galarneau@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.
- */
-
-#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 */
index 16463292bb9a350b630794536a3e5f1a1da0905a..403ed03da0dd5ea618736b4c12bb3b97cc008021 100644 (file)
  * SOFTWARE.
  */
 
+#define BT_LOG_OUTPUT_LEVEL log_level
+#define BT_LOG_TAG "PLUGIN/SRC.CTF.FS/META"
+#include "logging/log.h"
+
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -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;
index 5df82599fe2194f1c6fec10c9d824083cf21191f..6f78505b078da3d5799158b04ffa3faf2f9a5541 100644 (file)
  * 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 <stdbool.h>
 #include "common/assert.h"
@@ -34,9 +38,6 @@
 #include <babeltrace2/babeltrace.h>
 #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;
        }
index 35ee4b6cfd5834450c698044df8bd49994388ced..89e31838f86cbbd1040146093ffc2e711c9ef2d5 100644 (file)
 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 */
This page took 0.039759 seconds and 4 git commands to generate.