Logging: add `src/plugins/comp-logging.h` (BT_COMP_LOG*())
This new header is intended to be included by the different component
class files so that their logging statements can automatically include
the component's name. The BT_COMP_LOG*() macros prepend a prefix similar
to this to the logging message:
[mein-sink]
where `mein-sink` is a component's name.
Having the component name within each logging message of a given
component class adds valuable context and can help resolve issues
faster.
I did not include the plugin name and the component class's type and
name within the prefix because we already have them thanks to the
logging tag, for example `PLUGIN/SRC.CTF.FS`. This would be redundant,
make the logging message longer, and make `comp-logging.h` more complex.
The BT_COMP_LOG*() macros rely on the `BT_COMP_LOG_SELF_COMP`
definition. This is an expression which is, in the logging statement
context, the `bt_self_component *` address. Because we have the self
component there, we are free to prepend more contextual information to
the logging message in the future, should we need it.
Typically, when a component class source file defines
`BT_LOG_OUTPUT_LEVEL` to `(my_comp->log_level)`, where `my_comp` points
to the component's private structure, it will also define
`BT_COMP_LOG_SELF_COMP` to `(my_comp->self_comp)`.
If `BT_COMP_LOG_SELF_COMP` evaluates to `NULL`, the macros use the
prefix
[N/A]
This could be the case when instrumenting code that is shared for both
graph and non-graph contexts, for example the metadata and stream
decoders of the `ctf` plugin which can also be used within a query
operation.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I62c63ed78d234922f556631726fb7bb852924f0a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1468
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
This page took 0.029342 seconds and 4 git commands to generate.