Fix: cpp-common/bt2c/logging.hpp: don't set `_mSelfComp` when creating `Logger` for...
[babeltrace.git] / src / cpp-common / bt2c / logging.hpp
index beb64c26a4d680781e2c6566847b52eaca18e039..c732ef4ca5bb7402ef0e81f0e63674e60c8dbc5c 100644 (file)
@@ -115,9 +115,9 @@ public:
      * using the tag `tag`.
      */
     explicit Logger(const bt2::SelfMessageIterator selfMsgIter, std::string tag) noexcept :
-        Logger {selfMsgIter.component(), std::move(tag)}
+        _mSelfMsgIter {selfMsgIter},
+        _mLevel {static_cast<Level>(selfMsgIter.component().loggingLevel())}, _mTag {std::move(tag)}
     {
-        _mSelfMsgIter = selfMsgIter;
     }
 
     /*
@@ -559,17 +559,17 @@ private:
         if (AppendCauseV) {
             if (_mSelfMsgIter) {
                 bt_current_thread_error_append_cause_from_message_iterator(
-                    _mSelfMsgIter->libObjPtr(), fileName, lineNo, "%s%s", initMsg, _mBuf.data());
+                    _mSelfMsgIter->libObjPtr(), fileName, lineNo, "%s%s", initMsg, msg);
             } else if (_mSelfComp) {
                 bt_current_thread_error_append_cause_from_component(
-                    _mSelfComp->libObjPtr(), fileName, lineNo, "%s%s", initMsg, _mBuf.data());
+                    _mSelfComp->libObjPtr(), fileName, lineNo, "%s%s", initMsg, msg);
             } else if (_mSelfCompCls) {
                 bt_current_thread_error_append_cause_from_component_class(
-                    _mSelfCompCls->libObjPtr(), fileName, lineNo, "%s%s", initMsg, _mBuf.data());
+                    _mSelfCompCls->libObjPtr(), fileName, lineNo, "%s%s", initMsg, msg);
             } else {
                 BT_ASSERT(_mModuleName);
-                bt_current_thread_error_append_cause_from_unknown(
-                    _mModuleName->data(), fileName, lineNo, "%s%s", initMsg, _mBuf.data());
+                bt_current_thread_error_append_cause_from_unknown(_mModuleName->data(), fileName,
+                                                                  lineNo, "%s%s", initMsg, msg);
             }
         }
     }
@@ -580,7 +580,7 @@ private:
         return fmt::format("{}: {}", initMsg, g_strerror(errno));
     }
 
-    /* At least one of the following four members has a value */
+    /* Exactly one of the following four members has a value */
     bt2s::optional<bt2::SelfComponentClass> _mSelfCompCls;
     bt2s::optional<bt2::SelfComponent> _mSelfComp;
     bt2s::optional<bt2::SelfMessageIterator> _mSelfMsgIter;
This page took 0.042961 seconds and 4 git commands to generate.