ctf: use `bt2c::Logger` throughout `src.ctf.fs`, `src.ctf.lttng-live`
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 28 Mar 2024 18:31:12 +0000 (14:31 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
commit0f5c5d5ce30884c93b4e4d0662e2914029c3e90f
treea152825a98026d752a8db6a099a7cad00138292d
parent644c6ca70640ef866d636a634ceb1488fed09b53
ctf: use `bt2c::Logger` throughout `src.ctf.fs`, `src.ctf.lttng-live`

A lot of functions and structures have parameters or fields of type
`bt_self_component`, `bt_self_component_class` and `bt_logging_level`
for the sole purpose of logging.  This becomes quite verbose, especially
when a function can be used in both self component and self component
class context, then it will have both of these parameters.

The `bt2c::Logger` class exists to encapsulate this context in a single
value that can be passed around.  Use it as much as practically possible
(as well as the corresponding logging macros) throughout the sources of
the ctf plugin, as well as in the common directory that they depend on.

Update all format strings to use {fmt}'s format string syntax.

Change all "enum to string" functions to be `format_as()` functions
understood by {fmt}.  Move these functions near the type they format,
for convenience.

Remove all the macros that appear at the beginning of source files that
influence the logging (such as `BT_COMP_LOG_SELF_COMP` and `BT_LOG_TAG`).

The log tags were previously defined per-source file, whereas they are
now defined per `Logger` object.  I tried to re-use the existing log
tags when it made sense, but in some places the log tags are now a bit
more granular.

Remove the `ctf_plugin_metadata_log_level` variable, controlled by the
`BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL` environment variable.  This
variable controlled the logging level in the lexer and parser (generated
by flex and bison).   It existed because the generated lexer and parser
don't provide an easy way to pass user data around.

Work around this by define the following variable:

   thread_local const ctf_scanner *currentCtfScanner;

and making the logging in the lexer and parser code use
`currentCtfScanner->logger`.  Set `currentCtfScanner` when entering the
parser in `ctf_scanner_append_ast()` and install an RAII cleanup to
reset it.

Change-Id: I0f6844d2cb83d2bf52b81ae9dee4179c7b1f2e12
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12199
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
45 files changed:
src/Makefile.am
src/compat/socket.hpp
src/plugins/ctf/common/src/bfcr/bfcr.cpp
src/plugins/ctf/common/src/bfcr/bfcr.hpp
src/plugins/ctf/common/src/metadata/tsdl/ast.hpp
src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-resolve.cpp
src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-update-default-clock-classes.cpp
src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-validate.cpp
src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-visitors.hpp
src/plugins/ctf/common/src/metadata/tsdl/ctf-meta-warn-meaningless-header-fields.cpp
src/plugins/ctf/common/src/metadata/tsdl/ctf-meta.hpp
src/plugins/ctf/common/src/metadata/tsdl/decoder-packetized-file-stream-to-buf.cpp
src/plugins/ctf/common/src/metadata/tsdl/decoder-packetized-file-stream-to-buf.hpp
src/plugins/ctf/common/src/metadata/tsdl/decoder.cpp
src/plugins/ctf/common/src/metadata/tsdl/decoder.hpp
src/plugins/ctf/common/src/metadata/tsdl/lexer.lpp
src/plugins/ctf/common/src/metadata/tsdl/logging.cpp [deleted file]
src/plugins/ctf/common/src/metadata/tsdl/logging.hpp
src/plugins/ctf/common/src/metadata/tsdl/objstack.cpp
src/plugins/ctf/common/src/metadata/tsdl/objstack.hpp
src/plugins/ctf/common/src/metadata/tsdl/parser-wrap.hpp
src/plugins/ctf/common/src/metadata/tsdl/parser.ypp
src/plugins/ctf/common/src/metadata/tsdl/scanner.hpp
src/plugins/ctf/common/src/metadata/tsdl/visitor-generate-ir.cpp
src/plugins/ctf/common/src/metadata/tsdl/visitor-parent-links.cpp
src/plugins/ctf/common/src/metadata/tsdl/visitor-semantic-validator.cpp
src/plugins/ctf/common/src/msg-iter/msg-iter.cpp
src/plugins/ctf/common/src/msg-iter/msg-iter.hpp
src/plugins/ctf/fs-src/data-stream-file.cpp
src/plugins/ctf/fs-src/data-stream-file.hpp
src/plugins/ctf/fs-src/file.cpp
src/plugins/ctf/fs-src/file.hpp
src/plugins/ctf/fs-src/fs.cpp
src/plugins/ctf/fs-src/fs.hpp
src/plugins/ctf/fs-src/metadata.cpp
src/plugins/ctf/fs-src/metadata.hpp
src/plugins/ctf/fs-src/query.cpp
src/plugins/ctf/fs-src/query.hpp
src/plugins/ctf/lttng-live/data-stream.cpp
src/plugins/ctf/lttng-live/lttng-live.cpp
src/plugins/ctf/lttng-live/lttng-live.hpp
src/plugins/ctf/lttng-live/lttng-viewer-abi.hpp
src/plugins/ctf/lttng-live/metadata.cpp
src/plugins/ctf/lttng-live/viewer-connection.cpp
src/plugins/ctf/lttng-live/viewer-connection.hpp
This page took 0.029276 seconds and 4 git commands to generate.