From 862b5b546c2b90895cbbd4ab49579193e6bad972 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 27 Sep 2024 16:01:20 -0400 Subject: [PATCH] cpp-common/bt2c: Logger: add self component class constructor Make it possible to build a `Logger` from a self component class only (for instance, from the "get supported mip versions" method). Change-Id: Ic1d0abe8832eb5af831d5fa2b66b3d9737bcdee7 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/13294 Reviewed-by: Philippe Proulx --- src/cpp-common/bt2c/logging.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/cpp-common/bt2c/logging.hpp b/src/cpp-common/bt2c/logging.hpp index 347063ab..1d2285a0 100644 --- a/src/cpp-common/bt2c/logging.hpp +++ b/src/cpp-common/bt2c/logging.hpp @@ -86,6 +86,17 @@ public: /* clang-format on */ + /* + * Builds a logger from the self component class `selfCompCls` using + * the tag `tag` and the logging level `logLevel`. + */ + explicit Logger(const bt2::SelfComponentClass selfCompCls, const bt2::LoggingLevel logLevel, + std::string tag) noexcept : + _mSelfCompCls {selfCompCls}, + _mLevel {static_cast(logLevel)}, _mTag {std::move(tag)} + { + } + /* * Builds a logger from the self component class `selfCompCls` using * the tag `tag` and the logging level of `privQueryExec`. -- 2.34.1