cxx/core/log: convert funcname to string before adding tag
When testing !537 (merged) I noticed error messages caught by spdlog:
[*** LOG ERROR #0009 ***] [2025-01-14 18:31:40] [STAT] std::bad_cast [../cxx/constellation/core/metrics/MetricsManager.cpp(167)]
[*** LOG ERROR #0010 ***] [2025-01-14 18:31:41] [STAT] std::bad_cast [../cxx/constellation/core/metrics/MetricsManager.cpp(167)]
[*** LOG ERROR #0011 ***] [2025-01-14 18:31:42] [STAT] std::bad_cast [../cxx/constellation/core/metrics/MetricsManager.cpp(167)]
[*** LOG ERROR #0012 ***] [2025-01-14 18:31:43] [STAT] std::bad_cast [../cxx/constellation/core/metrics/MetricsManager.cpp(167)]
[*** LOG ERROR #0013 ***] [2025-01-14 18:31:44] [STAT] std::bad_cast [../cxx/constellation/core/metrics/MetricsManager.cpp(167)]
[*** LOG ERROR #0014 ***] [2025-01-14 18:31:45] [STAT] std::bad_cast [../cxx/constellation/core/metrics/MetricsManager.cpp(167)]
[*** LOG ERROR #0016 ***] [2025-01-14 18:31:47] [CMDP] std::bad_cast [../cxx/constellation/core/log/CMDPSink.cpp(124)]
some originalting from metrics, some from cmdp, some from chp. Checking the mentioned lines revealed, they all have in common to be TRACE
logging commands. a bisect between v0.2 and main
reveals this as the culprit:
commit c78f32c11da7284149797dd8f2c0c4537b338292 (HEAD)
Author: Stephan Lachnit <stephan.lachnit@desy.de>
Date: Thu Dec 12 15:41:57 2024 +0100
cxx: fix compilation for setting header tags
diff --git a/cxx/constellation/core/message/BaseHeader.hpp b/cxx/constellation/core/message/BaseHeader.hpp
index b72097a4..fafc8e65 100644
--- a/cxx/constellation/core/message/BaseHeader.hpp
+++ b/cxx/constellation/core/message/BaseHeader.hpp
@@ -61,8 +61,8 @@ namespace constellation::message {
}
/** Set message tag */
- void setTag(const std::string& key, config::Value value) {
- tags_[utils::transform(key, ::tolower)] = std::move(value);
+ template <typename T> void setTag(const std::string& key, const T& value) {
+ tags_[utils::transform(key, ::tolower)] = value;
}
/** Convert message header to human readable string */
So it seems some tag is set which cannot be cast to config::Value
. The culprit is quickly found as spdlog::source_loc::funcname
.
However
-
I think this is something that should be caught compile-time. -
I don't understand why CMDP1Message
objects are generated even if nobody (supposedly) is listening toTRACE
level messages...?