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)
commite874da19b9fd96ac87f70595e0463f8e03af29af
tree3edb55d3935e6eb65d3f41fa592cec2d42a94c5f
parent0ee90b745f28a543f7cc355591b36bddfe3a30e1
lib: set component's initial log level when adding it to the graph

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
This page took 0.027138 seconds and 4 git commands to generate.