lib: set component's initial log level when adding it to the graph
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 15 Jun 2019 01:16:07 +0000 (21:16 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 20 Jun 2019 18:01:16 +0000 (14:01 -0400)
This patch changes the bt_graph_add_*_component*() functions so that
they accept a log level parameter. This is now considered the
component's initial log level, so that we can achieve per-component log
levels.

The component initialization method types are not changed: because the
log level is part of a component's state, a component initialization
method can retrieve its own, current log level with the new
bt_component_get_logging_level() function. When you call
bt_graph_add_*_component*(), the function creates an initial component
object, sets its initial log level, and then calls its initialization
method.

Eventually, we can add a new, optional "logging level changed" component
method to notify it that its log level changed (caused by a call to
bt_component_set_logging_level(), for example).

The project's components do not honor their initial log level within the
scope of this patch: this is postponed to another patch. In other words,
they still use shared object constructors and environment variables to
set their log level at the component class level.

The CLI passes the configured log level (`--log-level`, `-v`, or `-d`
options) when it calls the bt_graph_add_*_component() functions. As of
this patch, it also still sets the known log level environment
variables.

Python bindings are adjusted accordingly. Their tests are not changed
because the log level parameter is optional (defaults to
`bt2.LoggingLevel.NONE`) and it's the last one of
bt2.Graph.add_component(). The constructor of `bt2.ComponentSpec` also
accepts a new, optional log level parameter to configure the component
specifier as such. You can access the log level of a component with the
new `logging_level` property.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: If258335f46ffabb587dd777b5109fc66d8a59f54
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1454
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
17 files changed:
include/babeltrace2/graph/component-const.h
include/babeltrace2/graph/graph.h
src/bindings/python/bt2/bt2/component.py
src/bindings/python/bt2/bt2/graph.py
src/bindings/python/bt2/bt2/native_bt_component.i
src/bindings/python/bt2/bt2/native_bt_graph.i
src/bindings/python/bt2/bt2/trace_collection_message_iterator.py
src/bindings/python/bt2/bt2/utils.py
src/cli/babeltrace2.c
src/lib/graph/component.c
src/lib/graph/component.h
src/lib/graph/graph.c
src/lib/graph/iterator.c
src/lib/lib-logging.c
tests/lib/test_graph_topo.c
tests/lib/test_plugin.c
tests/lib/test_trace_ir_ref.c

index 00884cdd0e717a46b8ac0a60268c67c4db1c0194..f74b58fc819652d98fa9a24901546c0089ce4191 100644 (file)
@@ -33,6 +33,9 @@
  */
 #include <babeltrace2/types.h>
 
+/* For bt_logging_level */
+#include <babeltrace2/logging.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -45,6 +48,9 @@ extern "C" {
  */
 extern const char *bt_component_get_name(const bt_component *component);
 
+extern bt_logging_level bt_component_get_logging_level(
+               const bt_component *component);
+
 /**
  * Get component's class.
  *
index f5bd52d58ea8ace6982670c77fc9e05c0e4571d1..34a74fa44f8b2b85fe7c1f6c4574613a6d9cd332 100644 (file)
@@ -36,6 +36,9 @@
 /* For bt_graph_status */
 #include <babeltrace2/graph/graph-const.h>
 
+/* For bt_logging_level */
+#include <babeltrace2/logging.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -102,36 +105,38 @@ extern bt_graph *bt_graph_create(void);
 extern bt_graph_status bt_graph_add_source_component(bt_graph *graph,
                const bt_component_class_source *component_class,
                const char *name, const bt_value *params,
-               const bt_component_source **component);
+               bt_logging_level log_level, const bt_component_source **component);
 
 extern bt_graph_status bt_graph_add_source_component_with_init_method_data(
                bt_graph *graph,
                const bt_component_class_source *component_class,
                const char *name, const bt_value *params,
-               void *init_method_data,
+               void *init_method_data, bt_logging_level log_level,
                const bt_component_source **component);
 
 extern bt_graph_status bt_graph_add_filter_component(bt_graph *graph,
                const bt_component_class_filter *component_class,
                const char *name, const bt_value *params,
+               bt_logging_level log_level,
                const bt_component_filter **component);
 
 extern bt_graph_status bt_graph_add_filter_component_with_init_method_data(
                bt_graph *graph,
                const bt_component_class_filter *component_class,
                const char *name, const bt_value *params,
-               void *init_method_data,
+               void *init_method_data, bt_logging_level log_level,
                const bt_component_filter **component);
 
 extern bt_graph_status bt_graph_add_sink_component(
                bt_graph *graph, const bt_component_class_sink *component_class,
                const char *name, const bt_value *params,
+               bt_logging_level log_level,
                const bt_component_sink **component);
 
 extern bt_graph_status bt_graph_add_sink_component_with_init_method_data(
                bt_graph *graph, const bt_component_class_sink *component_class,
                const char *name, const bt_value *params,
-               void *init_method_data,
+               void *init_method_data, bt_logging_level log_level,
                const bt_component_sink **component);
 
 extern bt_graph_status bt_graph_connect_ports(bt_graph *graph,
index 3480f6570703e2ae49db6c0a99d62daabf89b0a7..13c51bf8badfbe66e5ec0290fe6efab2ae02bbc4 100644 (file)
@@ -184,6 +184,11 @@ class _Component:
         assert name is not None
         return name
 
+    @property
+    def logging_level(self):
+        ptr = self._as_component_ptr(self._ptr)
+        return native_bt.component_get_logging_level(ptr)
+
     @property
     def cls(self):
         cc_ptr = self._borrow_component_class_ptr(self._ptr)
@@ -575,6 +580,12 @@ class _UserComponent(metaclass=_UserComponentType):
         assert name is not None
         return name
 
+    @property
+    def logging_level(self):
+        ptr = self._as_not_self_specific_component_ptr(self._ptr)
+        ptr = self._as_component_ptr(ptr)
+        return native_bt.component_get_logging_level(ptr)
+
     @property
     def cls(self):
         comp_ptr = self._as_not_self_specific_component_ptr(self._ptr)
index 998d310b3b268ea8d6640b5a6a06fe2180ee7a52..849b208a10e58dfa5e96611b12942837aa0cf6d3 100644 (file)
@@ -25,6 +25,7 @@ import bt2.connection
 import bt2.component
 import functools
 import bt2.port
+import bt2.logging
 import bt2
 
 
@@ -76,7 +77,8 @@ class Graph(object._SharedObject):
         elif status < 0:
             raise bt2.Error(gen_error_msg)
 
-    def add_component(self, component_class, name, params=None):
+    def add_component(self, component_class, name, params=None,
+                      logging_level=bt2.logging.LoggingLevel.NONE):
         if isinstance(component_class, bt2.component._GenericSourceComponentClass):
             cc_ptr = component_class._ptr
             add_fn = native_bt.graph_add_source_component
@@ -106,11 +108,13 @@ class Graph(object._SharedObject):
                 component_class.__class__.__name__))
 
         utils._check_str(name)
+        utils._check_log_level(logging_level)
         params = bt2.create_value(params)
 
         params_ptr = params._ptr if params is not None else None
 
-        status, comp_ptr = add_fn(self._ptr, cc_ptr, name, params_ptr)
+        status, comp_ptr = add_fn(self._ptr, cc_ptr, name,
+                                  params_ptr, logging_level)
         self._handle_status(status, 'cannot add component to graph')
         assert comp_ptr
         return bt2.component._create_component_from_ptr(comp_ptr, cc_type)
index f484263ecccad70bd6ff0411fa8a60bc3b237904..9eb946e8c9303366784e2ff213ed2823eec3db23 100644 (file)
@@ -86,6 +86,9 @@
 
 extern const char *bt_component_get_name(const bt_component *component);
 
+extern bt_logging_level bt_component_get_logging_level(
+               const bt_component *component);
+
 extern const bt_component_class *bt_component_borrow_class_const(
                const bt_component *component);
 
index bb7a5d133d4aefa9a3c0a722954ca9cbe7e09cf6..0fcb70eef95665ff0b0bade9df2ab0e76265b7ce 100644 (file)
@@ -184,36 +184,38 @@ extern bt_graph *bt_graph_create(void);
 extern bt_graph_status bt_graph_add_source_component(bt_graph *graph,
                const bt_component_class_source *component_class,
                const char *name, const bt_value *params,
-               const bt_component_source **OUT);
+               bt_logging_level log_level, const bt_component_source **OUT);
 
 extern bt_graph_status bt_graph_add_source_component_with_init_method_data(
                bt_graph *graph,
                const bt_component_class_source *component_class,
                const char *name, const bt_value *params,
-               void *init_method_data,
+               void *init_method_data, bt_logging_level log_level,
                const bt_component_source **OUT);
 
 extern bt_graph_status bt_graph_add_filter_component(bt_graph *graph,
                const bt_component_class_filter *component_class,
                const char *name, const bt_value *params,
+               bt_logging_level log_level,
                const bt_component_filter **OUT);
 
 extern bt_graph_status bt_graph_add_filter_component_with_init_method_data(
                bt_graph *graph,
                const bt_component_class_filter *component_class,
                const char *name, const bt_value *params,
-               void *init_method_data,
+               void *init_method_data, bt_logging_level log_level,
                const bt_component_filter **OUT);
 
 extern bt_graph_status bt_graph_add_sink_component(
                bt_graph *graph, const bt_component_class_sink *component_class,
                const char *name, const bt_value *params,
+               bt_logging_level log_level,
                const bt_component_sink **OUT);
 
 extern bt_graph_status bt_graph_add_sink_component_with_init_method_data(
                bt_graph *graph, const bt_component_class_sink *component_class,
                const char *name, const bt_value *params,
-               void *init_method_data,
+               void *init_method_data, bt_logging_level log_level,
                const bt_component_sink **OUT);
 
 extern bt_graph_status bt_graph_connect_ports(bt_graph *graph,
@@ -326,7 +328,7 @@ port_added_listener(
                status = BT_GRAPH_LISTENER_STATUS_ERROR;
                goto end;
        }
-       
+
        BT_ASSERT(py_res == Py_None);
        status = BT_GRAPH_LISTENER_STATUS_OK;
 
@@ -512,7 +514,7 @@ ports_connected_listener(
                status = BT_GRAPH_LISTENER_STATUS_NOMEM;
                goto end;
        }
-       
+
        py_downstream_component_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(downstream_component),
                downstream_component_swig_type, 0);
        if (!py_downstream_component_ptr) {
@@ -540,7 +542,7 @@ ports_connected_listener(
                status = BT_GRAPH_LISTENER_STATUS_ERROR;
                goto end;
        }
-       
+
        BT_ASSERT(py_res == Py_None);
        status = BT_GRAPH_LISTENER_STATUS_OK;
 
index 10b555f18f6953bf0ee59370dda106c8ca26a194..25778fccaa7fbc636fc5f8f82b31000e311b5d3c 100644 (file)
@@ -34,11 +34,14 @@ _ComponentAndSpec = namedtuple('_ComponentAndSpec', ['comp', 'spec'])
 
 
 class ComponentSpec:
-    def __init__(self, plugin_name, class_name, params=None):
+    def __init__(self, plugin_name, class_name, params=None,
+                 logging_level=bt2.logging.LoggingLevel.NONE):
         utils._check_str(plugin_name)
         utils._check_str(class_name)
+        utils._check_log_level(logging_level)
         self._plugin_name = plugin_name
         self._class_name = class_name
+        self._logging_level = logging_level
 
         if type(params) is str:
             self._params = bt2.create_value({'paths': [params]})
@@ -53,6 +56,10 @@ class ComponentSpec:
     def class_name(self):
         return self._class_name
 
+    @property
+    def logging_level(self):
+        return self._logging_level
+
     @property
     def params(self):
         return self._params
@@ -226,7 +233,8 @@ class TraceCollectionMessageIterator(bt2.message_iterator._MessageIterator):
 
         comp_cls = comp_classes[comp_spec.class_name]
         name = self._get_unique_comp_name(comp_spec)
-        comp = self._graph.add_component(comp_cls, name, comp_spec.params)
+        comp = self._graph.add_component(comp_cls, name, comp_spec.params,
+                                         comp_spec.logging_level)
         return comp
 
     def _get_free_muxer_input_port(self):
index b564fcad1b486aa57ae2b27ca613d6ff3f517eb9..4329d93fa17565f31dcf4aaec06e33a5e1132c36 100644 (file)
@@ -21,6 +21,7 @@
 # THE SOFTWARE.
 
 import bt2
+import bt2.logging
 
 
 def _check_bool(o):
@@ -125,3 +126,20 @@ def _handle_ret(ret, msg=None):
 def _handle_ptr(ptr, msg=None):
     if ptr is None:
         _raise_bt2_error(msg)
+
+
+def _check_log_level(log_level):
+    _check_int(log_level)
+
+    log_levels = (
+        bt2.logging.LoggingLevel.VERBOSE,
+        bt2.logging.LoggingLevel.DEBUG,
+        bt2.logging.LoggingLevel.INFO,
+        bt2.logging.LoggingLevel.WARN,
+        bt2.logging.LoggingLevel.ERROR,
+        bt2.logging.LoggingLevel.FATAL,
+        bt2.logging.LoggingLevel.NONE,
+    )
+
+    if log_level not in log_levels:
+        raise ValueError("'{}' is not a valid logging level".format(log_level))
index 346938a9e4f367a8f998c0cba733c97856f5b77d..7da507126553af5449bbffb63c65ea2adafb32a4 100644 (file)
@@ -1782,7 +1782,8 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component(
                        ctx->connect_ports = false;
                        graph_status = bt_graph_add_filter_component(
                                ctx->graph, trimmer_class, trimmer_name,
-                               trimmer_params, &trimmer);
+                               trimmer_params, ctx->cfg->log_level,
+                               &trimmer);
                        free(trimmer_name);
                        if (graph_status != BT_GRAPH_STATUS_OK) {
                                goto error;
@@ -2394,19 +2395,19 @@ int cmd_run_ctx_create_components_from_config_components(
                case BT_COMPONENT_CLASS_TYPE_SOURCE:
                        ret = bt_graph_add_source_component(ctx->graph,
                                comp_cls, cfg_comp->instance_name->str,
-                               cfg_comp->params,
+                               cfg_comp->params, ctx->cfg->log_level,
                                (void *) &comp);
                        break;
                case BT_COMPONENT_CLASS_TYPE_FILTER:
                        ret = bt_graph_add_filter_component(ctx->graph,
                                comp_cls, cfg_comp->instance_name->str,
-                               cfg_comp->params,
+                               cfg_comp->params, ctx->cfg->log_level,
                                (void *) &comp);
                        break;
                case BT_COMPONENT_CLASS_TYPE_SINK:
                        ret = bt_graph_add_sink_component(ctx->graph,
                                comp_cls, cfg_comp->instance_name->str,
-                               cfg_comp->params,
+                               cfg_comp->params, ctx->cfg->log_level,
                                (void *) &comp);
                        break;
                default:
index 3bb901faf20212c2c76ddf4d1d633dbd06bf34d2..b02d2a8cfcd293d364e2e6ae7706d2dc4f1bd5a9 100644 (file)
@@ -24,6 +24,7 @@
 #define BT_LOG_TAG "LIB/COMPONENT"
 #include "lib/lib-logging.h"
 
+#include "common/common.h"
 #include "common/assert.h"
 #include "lib/assert-pre.h"
 #include <babeltrace2/graph/self-component.h>
@@ -282,7 +283,8 @@ uint64_t bt_component_get_output_port_count(const struct bt_component *comp)
 
 BT_HIDDEN
 int bt_component_create(struct bt_component_class *component_class,
-               const char *name, struct bt_component **user_component)
+               const char *name, bt_logging_level log_level,
+               struct bt_component **user_component)
 {
        int ret = 0;
        struct bt_component *component = NULL;
@@ -293,7 +295,8 @@ int bt_component_create(struct bt_component_class *component_class,
        BT_ASSERT(name);
        type = bt_component_class_get_type(component_class);
        BT_LIB_LOGI("Creating empty component from component class: %![cc-]+C, "
-               "comp-name=\"%s\"", component_class, name);
+               "comp-name=\"%s\", log-level=%s", component_class, name,
+               bt_common_logging_level_string(log_level));
        component = component_create_funcs[type](component_class);
        if (!component) {
                BT_LOGE_STR("Cannot create specific component object.");
@@ -312,6 +315,7 @@ int bt_component_create(struct bt_component_class *component_class,
                goto end;
        }
 
+       component->log_level = log_level;
        component->input_ports = g_ptr_array_new_with_free_func(
                (GDestroyNotify) bt_object_try_spec_release);
        if (!component->input_ports) {
@@ -674,6 +678,13 @@ void bt_component_remove_destroy_listener(struct bt_component *component,
        }
 }
 
+bt_logging_level bt_component_get_logging_level(
+               const struct bt_component *component)
+{
+       BT_ASSERT_PRE_NON_NULL(component, "Component");
+       return component->log_level;
+}
+
 void bt_component_get_ref(const struct bt_component *component)
 {
        bt_object_get_ref(component);
index 285a8e9a74ffe24fb932cd68e7d5c08182aa5951..2155d5da203ca6bcbf5acb0edee384c440dae7fa 100644 (file)
@@ -28,6 +28,7 @@
 #include <babeltrace2/graph/component-const.h>
 #include "lib/object.h"
 #include <babeltrace2/types.h>
+#include <babeltrace2/logging.h>
 #include "common/assert.h"
 #include <glib.h>
 #include <stdio.h>
@@ -49,6 +50,7 @@ struct bt_component {
        struct bt_object base;
        struct bt_component_class *class;
        GString *name;
+       bt_logging_level log_level;
 
        /*
         * Internal destroy function specific to a source, filter, or
@@ -78,7 +80,8 @@ struct bt_graph *bt_component_borrow_graph(struct bt_component *comp)
 
 BT_HIDDEN
 int bt_component_create(struct bt_component_class *component_class,
-               const char *name, struct bt_component **component);
+               const char *name, bt_logging_level log_level,
+               struct bt_component **component);
 
 BT_HIDDEN
 enum bt_self_component_status bt_component_accept_port_connection(
index f738559e3405fc7e64a61f8223c3676e5330684b..70d958fc196bd1924dd449a2334b985ff52d273e 100644 (file)
@@ -1269,7 +1269,8 @@ enum bt_graph_status add_component_with_init_method_data(
                struct bt_component_class *comp_cls,
                comp_init_method_t init_method,
                const char *name, const struct bt_value *params,
-               void *init_method_data, struct bt_component **user_component)
+               void *init_method_data, bt_logging_level log_level,
+               struct bt_component **user_component)
 {
        enum bt_graph_status graph_status = BT_GRAPH_STATUS_OK;
        enum bt_self_component_status comp_status;
@@ -1292,9 +1293,11 @@ enum bt_graph_status add_component_with_init_method_data(
        init_can_consume = graph->can_consume;
        bt_graph_set_can_consume(graph, false);
        BT_LIB_LOGI("Adding component to graph: "
-               "%![graph-]+g, %![cc-]+C, name=\"%s\", %![params-]+v, "
-               "init-method-data-addr=%p",
-               graph, comp_cls, name, params, init_method_data);
+               "%![graph-]+g, %![cc-]+C, name=\"%s\", log-level=%s, "
+               "%![params-]+v, init-method-data-addr=%p",
+               graph, comp_cls, name,
+               bt_common_logging_level_string(log_level), params,
+               init_method_data);
 
        if (!params) {
                new_params = bt_value_map_create();
@@ -1307,7 +1310,7 @@ enum bt_graph_status add_component_with_init_method_data(
                params = new_params;
        }
 
-       ret = bt_component_create(comp_cls, name, &component);
+       ret = bt_component_create(comp_cls, name, log_level, &component);
        if (ret) {
                BT_LOGE("Cannot create empty component object: ret=%d",
                        ret);
@@ -1360,9 +1363,11 @@ enum bt_graph_status add_component_with_init_method_data(
        BT_LOGD_STR("Freezing component class.");
        bt_component_class_freeze(comp_cls);
        BT_LIB_LOGI("Added component to graph: "
-               "%![graph-]+g, %![cc-]+C, name=\"%s\", %![params-]+v, "
-               "init-method-data-addr=%p, %![comp-]+c",
-               graph, comp_cls, name, params, init_method_data, component);
+               "%![graph-]+g, %![cc-]+C, name=\"%s\", log-level=%s, "
+               "%![params-]+v, init-method-data-addr=%p, %![comp-]+c",
+               graph, comp_cls, name,
+               bt_common_logging_level_string(log_level), params,
+               init_method_data, component);
 
        if (user_component) {
                /* Move reference to user */
@@ -1387,23 +1392,24 @@ bt_graph_add_source_component_with_init_method_data(
                struct bt_graph *graph,
                const struct bt_component_class_source *comp_cls,
                const char *name, const struct bt_value *params,
-               void *init_method_data,
+               void *init_method_data, bt_logging_level log_level,
                const struct bt_component_source **component)
 {
        BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
        return add_component_with_init_method_data(graph,
                (void *) comp_cls, (comp_init_method_t) comp_cls->methods.init,
-               name, params, init_method_data, (void *) component);
+               name, params, init_method_data, log_level, (void *) component);
 }
 
 enum bt_graph_status bt_graph_add_source_component(
                struct bt_graph *graph,
                const struct bt_component_class_source *comp_cls,
                const char *name, const struct bt_value *params,
+               bt_logging_level log_level,
                const struct bt_component_source **component)
 {
        return bt_graph_add_source_component_with_init_method_data(
-               graph, comp_cls, name, params, NULL, component);
+               graph, comp_cls, name, params, NULL, log_level, component);
 }
 
 enum bt_graph_status
@@ -1411,23 +1417,24 @@ bt_graph_add_filter_component_with_init_method_data(
                struct bt_graph *graph,
                const struct bt_component_class_filter *comp_cls,
                const char *name, const struct bt_value *params,
-               void *init_method_data,
+               void *init_method_data, bt_logging_level log_level,
                const struct bt_component_filter **component)
 {
        BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
        return add_component_with_init_method_data(graph,
                (void *) comp_cls, (comp_init_method_t) comp_cls->methods.init,
-               name, params, init_method_data, (void *) component);
+               name, params, init_method_data, log_level, (void *) component);
 }
 
 enum bt_graph_status bt_graph_add_filter_component(
                struct bt_graph *graph,
                const struct bt_component_class_filter *comp_cls,
                const char *name, const struct bt_value *params,
+               bt_logging_level log_level,
                const struct bt_component_filter **component)
 {
        return bt_graph_add_filter_component_with_init_method_data(
-               graph, comp_cls, name, params, NULL, component);
+               graph, comp_cls, name, params, NULL, log_level, component);
 }
 
 enum bt_graph_status
@@ -1435,23 +1442,24 @@ bt_graph_add_sink_component_with_init_method_data(
                struct bt_graph *graph,
                const struct bt_component_class_sink *comp_cls,
                const char *name, const struct bt_value *params,
-               void *init_method_data,
+               void *init_method_data, bt_logging_level log_level,
                const struct bt_component_sink **component)
 {
        BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
        return add_component_with_init_method_data(graph,
                (void *) comp_cls, (comp_init_method_t) comp_cls->methods.init,
-               name, params, init_method_data, (void *) component);
+               name, params, init_method_data, log_level, (void *) component);
 }
 
 enum bt_graph_status bt_graph_add_sink_component(
                struct bt_graph *graph,
                const struct bt_component_class_sink *comp_cls,
                const char *name, const struct bt_value *params,
+               bt_logging_level log_level,
                const struct bt_component_sink **component)
 {
        return bt_graph_add_sink_component_with_init_method_data(
-               graph, comp_cls, name, params, NULL, component);
+               graph, comp_cls, name, params, NULL, log_level, component);
 }
 
 BT_HIDDEN
index e215203960867914cbe6616b99a46b09e202a0db..1303003f4963d7dbcc6f67963f89004590d2c0b8 100644 (file)
@@ -745,12 +745,19 @@ bt_port_output_message_iterator_create(struct bt_graph *graph,
        colander_data.msgs = (void *) iterator->base.msgs->pdata;
        colander_data.count_addr = &iterator->count;
 
-       /* Hope that nobody uses this very unique name */
+       /*
+        * Hope that nobody uses this very unique name.
+        *
+        * We pass `BT_LOGGING_LEVEL_NONE` but the colander component
+        * class module does not use this level anyway since it belongs
+        * to the library.
+        */
        graph_status =
                bt_graph_add_sink_component_with_init_method_data(
                        (void *) graph, colander_comp_cls,
                        "colander-36ac3409-b1a8-4d60-ab1f-4fdf341a8fb1",
-                       NULL, &colander_data, (void *) &iterator->colander);
+                       NULL, &colander_data, BT_LOGGING_LEVEL_NONE,
+                       (void *) &iterator->colander);
        if (graph_status != BT_GRAPH_STATUS_OK) {
                BT_LIB_LOGW("Cannot add colander sink component to graph: "
                        "%1[graph-]+g, status=%s", graph,
index e29c2e901281b964c94c859b1ec8b8ccd7892a78..1433489b652d7692f5b790ceace8bdebc75e0c94 100644 (file)
@@ -1055,8 +1055,9 @@ static inline void format_component(char **buf_ch, bool extended,
 {
        char tmp_prefix[TMP_PREFIX_LEN];
 
-       BUF_APPEND(", %sname=\"%s\"",
-               PRFIELD_GSTRING(component->name));
+       BUF_APPEND(", %sname=\"%s\", %slog-level=%s",
+               PRFIELD_GSTRING(component->name),
+               PRFIELD(bt_common_logging_level_string(component->log_level)));
 
        if (component->class) {
                SET_TMP_PREFIX("class-");
index 7a85f511cfa4584718cb036e7365670d52dfc52f..0a3111cdfeecbfa4f10167a8b02057e1b3c9de4a 100644 (file)
@@ -527,7 +527,7 @@ const bt_component_source *create_src(bt_graph *graph)
        int ret;
 
        ret = bt_graph_add_source_component(graph, src_comp_class,
-               "src-comp", NULL, &comp);
+               "src-comp", NULL, BT_LOGGING_LEVEL_NONE, &comp);
        BT_ASSERT(ret == 0);
        return comp;
 }
@@ -539,7 +539,7 @@ const bt_component_sink *create_sink(bt_graph *graph)
        int ret;
 
        ret = bt_graph_add_sink_component(graph, sink_comp_class,
-               "sink-comp", NULL, &comp);
+               "sink-comp", NULL, BT_LOGGING_LEVEL_NONE, &comp);
        BT_ASSERT(ret == 0);
        return comp;
 }
index 39b054e53ee3ddac324839284d9fa04fc12fce2f..bd96bd0b195de21fe37ace5c435853fff63a31bf 100644 (file)
@@ -195,7 +195,7 @@ static void test_sfs(const char *plugin_dir)
        graph = bt_graph_create();
        BT_ASSERT(graph);
        graph_ret = bt_graph_add_sink_component(graph, sink_comp_class,
-               "the-sink", NULL, &sink_component);
+               "the-sink", NULL, BT_LOGGING_LEVEL_NONE, &sink_component);
        ok(graph_ret == BT_GRAPH_STATUS_OK && sink_component,
                "bt_graph_add_sink_component() still works after the plugin object is destroyed");
        BT_COMPONENT_SINK_PUT_REF_AND_RESET(sink_component);
index 72bbbd6b7321b71ed8c8605bb4a27cb81308533b..53eaca01a4923f45fd7c95d7c01935521b8e0ec2 100644 (file)
@@ -471,7 +471,7 @@ static void test_example_scenario_in_graph(void)
        BT_ASSERT(ret == 0);
        graph = bt_graph_create();
        ret = bt_graph_add_source_component(graph, comp_cls, "src-comp",
-               NULL, NULL);
+               NULL, BT_LOGGING_LEVEL_NONE, NULL);
        BT_ASSERT(ret == 0);
        bt_graph_put_ref(graph);
        bt_component_class_source_put_ref(comp_cls);
This page took 0.035961 seconds and 4 git commands to generate.