From 1876c99c6b68dd213c5499e0c55090efced39804 Mon Sep 17 00:00:00 2001 From: Ernst Hellbar Date: Tue, 11 Feb 2025 15:49:33 +0100 Subject: [PATCH 1/5] Add new FairLogger severity (critical) to DPL and DebugGUI --- .../Core/include/Framework/LogParsingHelpers.h | 2 ++ Framework/Core/src/LogParsingHelpers.cxx | 6 ++++++ Framework/Core/src/runDataProcessing.cxx | 4 ++++ Framework/DataTakingSupport/src/Plugin.cxx | 8 ++++++-- Framework/GUISupport/src/FrameworkGUIDebugger.cxx | 14 ++++++++++++++ .../GUISupport/src/FrameworkGUIDevicesGraph.cxx | 8 ++++++++ 6 files changed, 40 insertions(+), 2 deletions(-) diff --git a/Framework/Core/include/Framework/LogParsingHelpers.h b/Framework/Core/include/Framework/LogParsingHelpers.h index 6af2c6e52886c..7f3909c2eaadd 100644 --- a/Framework/Core/include/Framework/LogParsingHelpers.h +++ b/Framework/Core/include/Framework/LogParsingHelpers.h @@ -23,9 +23,11 @@ struct LogParsingHelpers { enum struct LogLevel { Debug, Info, + Important, Warning, Alarm, Error, + Critical, Fatal, Unknown, Size diff --git a/Framework/Core/src/LogParsingHelpers.cxx b/Framework/Core/src/LogParsingHelpers.cxx index 58da49caee4da..0d309f28928ba 100644 --- a/Framework/Core/src/LogParsingHelpers.cxx +++ b/Framework/Core/src/LogParsingHelpers.cxx @@ -17,9 +17,11 @@ namespace o2::framework char const* const LogParsingHelpers::LOG_LEVELS[(int)LogParsingHelpers::LogLevel::Size] = { "DEBUG", "INFO", + "IMPORTANT", "WARNING", "ALARM", "ERROR", + "CRITICAL", "FATAL", "UNKNOWN"}; using LogLevel = o2::framework::LogParsingHelpers::LogLevel; @@ -59,12 +61,16 @@ LogLevel LogParsingHelpers::parseTokenLevel(std::string_view const s) } else if (s.compare(LABELPOS, 7, "[INFO] ") == 0 || s.compare(LABELPOS, 8, "[STATE] ") == 0) { return LogLevel::Info; + } else if (s.compare(LABELPOS, 12, "[IMPORTANT] ") == 0) { + return LogLevel::Important; } else if (s.compare(LABELPOS, 7, "[WARN] ") == 0) { return LogLevel::Warning; } else if (s.compare(LABELPOS, 8, "[ALARM] ") == 0) { return LogLevel::Alarm; } else if (s.compare(LABELPOS, 8, "[ERROR] ") == 0) { return LogLevel::Error; + } else if (s.compare(LABELPOS, 11, "[CRITICAL] ") == 0) { + return LogLevel::Critical; } else if (s.compare(LABELPOS, 8, "[FATAL] ") == 0) { return LogLevel::Fatal; } diff --git a/Framework/Core/src/runDataProcessing.cxx b/Framework/Core/src/runDataProcessing.cxx index 66fc2c7b2c3df..6c38945039d84 100644 --- a/Framework/Core/src/runDataProcessing.cxx +++ b/Framework/Core/src/runDataProcessing.cxx @@ -2141,6 +2141,8 @@ int runStateMachine(DataProcessorSpecs const& workflow, info.logLevel = LogParsingHelpers::LogLevel::Info; } else if ((*logLevelIt).compare("alarm") == 0) { info.logLevel = LogParsingHelpers::LogLevel::Alarm; + } else if ((*logLevelIt).compare("critical") == 0) { + info.logLevel = LogParsingHelpers::LogLevel::Critical; } else if ((*logLevelIt).compare("fatal") == 0) { info.logLevel = LogParsingHelpers::LogLevel::Fatal; } @@ -3159,6 +3161,8 @@ int doMain(int argc, char** argv, o2::framework::WorkflowSpec const& workflow, fair::Logger::SetConsoleSeverity(fair::Severity::important); } else if (logLevel == "alarm") { fair::Logger::SetConsoleSeverity(fair::Severity::alarm); + } else if (logLevel == "critical") { + fair::Logger::SetConsoleSeverity(fair::Severity::critical); } else if (logLevel == "fatal") { fair::Logger::SetConsoleSeverity(fair::Severity::fatal); } else { diff --git a/Framework/DataTakingSupport/src/Plugin.cxx b/Framework/DataTakingSupport/src/Plugin.cxx index e80e3f359f1be..f3dc23e26b114 100644 --- a/Framework/DataTakingSupport/src/Plugin.cxx +++ b/Framework/DataTakingSupport/src/Plugin.cxx @@ -72,6 +72,10 @@ auto createInfoLoggerSinkHelper(InfoLogger* logger, InfoLoggerContext* ctx) severity = InfoLogger::Severity::Fatal; level = 1; break; + case fair::Severity::critical: + severity = InfoLogger::Severity::Error; + level = 1; + break; case fair::Severity::error: severity = InfoLogger::Severity::Error; level = 2; @@ -132,8 +136,8 @@ auto createInfoLoggerSinkHelper(InfoLogger* logger, InfoLoggerContext* ctx) severity, level, InfoLogger::undefinedMessageOption.errorCode, - metadata.file.data(), - atoi(metadata.line.data())}; + metadata.file, + atoi(std::string(metadata.line.data(), metadata.line.size()).c_str())}; if (logger) { logger->log(opt, *ctx, "%s", content.c_str()); diff --git a/Framework/GUISupport/src/FrameworkGUIDebugger.cxx b/Framework/GUISupport/src/FrameworkGUIDebugger.cxx index 1e7942b5c22f7..112797d357458 100644 --- a/Framework/GUISupport/src/FrameworkGUIDebugger.cxx +++ b/Framework/GUISupport/src/FrameworkGUIDebugger.cxx @@ -69,6 +69,8 @@ ImVec4 colorForLogLevel(LogParsingHelpers::LogLevel logLevel) switch (logLevel) { case LogParsingHelpers::LogLevel::Info: return PaletteHelpers::GREEN; + case LogParsingHelpers::LogLevel::Important: + return PaletteHelpers::GREEN; case LogParsingHelpers::LogLevel::Debug: return PaletteHelpers::WHITE; case LogParsingHelpers::LogLevel::Alarm: @@ -77,6 +79,8 @@ ImVec4 colorForLogLevel(LogParsingHelpers::LogLevel logLevel) return PaletteHelpers::DARK_YELLOW; case LogParsingHelpers::LogLevel::Error: return PaletteHelpers::RED; + case LogParsingHelpers::LogLevel::Critical: + return PaletteHelpers::RED; case LogParsingHelpers::LogLevel::Fatal: return PaletteHelpers::RED; case LogParsingHelpers::LogLevel::Unknown: @@ -977,11 +981,21 @@ void pushWindowColorDueToStatus(const DeviceInfo& info) return; } switch (info.maxLogLevel) { + case LogLevel::Critical: + ImGui::PushStyleColor(ImGuiCol_TitleBg, PaletteHelpers::SHADED_RED); + ImGui::PushStyleColor(ImGuiCol_TitleBgActive, PaletteHelpers::RED); + ImGui::PushStyleColor(ImGuiCol_TitleBgCollapsed, PaletteHelpers::SHADED_RED); + break; case LogLevel::Error: ImGui::PushStyleColor(ImGuiCol_TitleBg, PaletteHelpers::SHADED_RED); ImGui::PushStyleColor(ImGuiCol_TitleBgActive, PaletteHelpers::RED); ImGui::PushStyleColor(ImGuiCol_TitleBgCollapsed, PaletteHelpers::SHADED_RED); break; + case LogLevel::Alarm: + ImGui::PushStyleColor(ImGuiCol_TitleBg, PaletteHelpers::SHADED_YELLOW); + ImGui::PushStyleColor(ImGuiCol_TitleBgActive, PaletteHelpers::YELLOW); + ImGui::PushStyleColor(ImGuiCol_TitleBgCollapsed, PaletteHelpers::SHADED_YELLOW); + break; case LogLevel::Warning: ImGui::PushStyleColor(ImGuiCol_TitleBg, PaletteHelpers::SHADED_YELLOW); ImGui::PushStyleColor(ImGuiCol_TitleBgActive, PaletteHelpers::YELLOW); diff --git a/Framework/GUISupport/src/FrameworkGUIDevicesGraph.cxx b/Framework/GUISupport/src/FrameworkGUIDevicesGraph.cxx index a7e781ffba275..89126cf303a66 100644 --- a/Framework/GUISupport/src/FrameworkGUIDevicesGraph.cxx +++ b/Framework/GUISupport/src/FrameworkGUIDevicesGraph.cxx @@ -694,10 +694,18 @@ void showTopologyNodeGraph(WorkspaceGUIState& state, ImGui::BeginGroup(); // Lock horizontal position ImGui::TextUnformatted(node->Name); switch (info.maxLogLevel) { + case LogLevel::Critical: + ImGui::SameLine(); + ImGui::TextColored(ERROR_MESSAGE_COLOR, "%s", ICON_FA_EXCLAMATION_CIRCLE); + break; case LogLevel::Error: ImGui::SameLine(); ImGui::TextColored(ERROR_MESSAGE_COLOR, "%s", ICON_FA_EXCLAMATION_CIRCLE); break; + case LogLevel::Alarm: + ImGui::SameLine(); + ImGui::TextColored(WARNING_MESSAGE_COLOR, "%s", ICON_FA_EXCLAMATION_TRIANGLE); + break; case LogLevel::Warning: ImGui::SameLine(); ImGui::TextColored(WARNING_MESSAGE_COLOR, "%s", ICON_FA_EXCLAMATION_TRIANGLE); From 2eabb7fd2cb459116823d7d251619d417a7ac89d Mon Sep 17 00:00:00 2001 From: Ernst Hellbar Date: Wed, 12 Feb 2025 15:44:27 +0100 Subject: [PATCH 2/5] Adding O2_SIGNPOST_EVENT_EMIT_CRITICAL macro --- Framework/Foundation/include/Framework/Signpost.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Framework/Foundation/include/Framework/Signpost.h b/Framework/Foundation/include/Framework/Signpost.h index ba807865a1195..4106174059b3c 100644 --- a/Framework/Foundation/include/Framework/Signpost.h +++ b/Framework/Foundation/include/Framework/Signpost.h @@ -531,6 +531,16 @@ void o2_debug_log_set_stacktrace(_o2_log_t* log, int stacktrace) O2_LOG_MACRO_RAW(warn, remove_engineering_type(format).data(), ##__VA_ARGS__); \ }) +// Similar to the above, however it will also print a normal critical message regardless of the signpost being enabled or not. +#define O2_SIGNPOST_EVENT_EMIT_CRITICAL(log, id, name, format, ...) __extension__({ \ + if (O2_BUILTIN_UNLIKELY(O2_SIGNPOST_ENABLED_MAC(log))) { \ + O2_SIGNPOST_EVENT_EMIT_MAC(log, id, name, format, ##__VA_ARGS__); \ + } else if (O2_BUILTIN_UNLIKELY(private_o2_log_##log->stacktrace)) { \ + _o2_signpost_event_emit(private_o2_log_##log, id, name, remove_engineering_type(format).data(), ##__VA_ARGS__); \ + } \ + O2_LOG_MACRO_RAW(critical, remove_engineering_type(format).data(), ##__VA_ARGS__); \ +}) + #define O2_SIGNPOST_START(log, id, name, format, ...) \ if (O2_BUILTIN_UNLIKELY(O2_SIGNPOST_ENABLED_MAC(log))) { \ O2_SIGNPOST_START_MAC(log, id, name, format, ##__VA_ARGS__); \ From 50dc348f4bd2acf9bfe7be663dcd565cec62c39b Mon Sep 17 00:00:00 2001 From: Ernst Hellbar Date: Thu, 13 Feb 2025 09:01:22 +0100 Subject: [PATCH 3/5] fixing formatting errors --- Framework/Foundation/include/Framework/Signpost.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Framework/Foundation/include/Framework/Signpost.h b/Framework/Foundation/include/Framework/Signpost.h index 4106174059b3c..7010301d80b44 100644 --- a/Framework/Foundation/include/Framework/Signpost.h +++ b/Framework/Foundation/include/Framework/Signpost.h @@ -532,13 +532,13 @@ void o2_debug_log_set_stacktrace(_o2_log_t* log, int stacktrace) }) // Similar to the above, however it will also print a normal critical message regardless of the signpost being enabled or not. -#define O2_SIGNPOST_EVENT_EMIT_CRITICAL(log, id, name, format, ...) __extension__({ \ +#define O2_SIGNPOST_EVENT_EMIT_CRITICAL(log, id, name, format, ...) __extension__({ \ if (O2_BUILTIN_UNLIKELY(O2_SIGNPOST_ENABLED_MAC(log))) { \ O2_SIGNPOST_EVENT_EMIT_MAC(log, id, name, format, ##__VA_ARGS__); \ } else if (O2_BUILTIN_UNLIKELY(private_o2_log_##log->stacktrace)) { \ _o2_signpost_event_emit(private_o2_log_##log, id, name, remove_engineering_type(format).data(), ##__VA_ARGS__); \ } \ - O2_LOG_MACRO_RAW(critical, remove_engineering_type(format).data(), ##__VA_ARGS__); \ + O2_LOG_MACRO_RAW(critical, remove_engineering_type(format).data(), ##__VA_ARGS__); \ }) #define O2_SIGNPOST_START(log, id, name, format, ...) \ From a9290332e8e3e980aeaadae172b4a2da13ae4c61 Mon Sep 17 00:00:00 2001 From: Ernst Hellbar Date: Thu, 20 Feb 2025 08:50:39 +0100 Subject: [PATCH 4/5] adding GPUCritical, putting InfoLoggerMessageOption initializer to log() call --- Framework/DataTakingSupport/src/Plugin.cxx | 14 ++++++-------- GPU/GPUTracking/Definitions/GPULogging.h | 4 ++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Framework/DataTakingSupport/src/Plugin.cxx b/Framework/DataTakingSupport/src/Plugin.cxx index f3dc23e26b114..42cb4f6773fda 100644 --- a/Framework/DataTakingSupport/src/Plugin.cxx +++ b/Framework/DataTakingSupport/src/Plugin.cxx @@ -132,15 +132,13 @@ auto createInfoLoggerSinkHelper(InfoLogger* logger, InfoLoggerContext* ctx) return; } - InfoLogger::InfoLoggerMessageOption opt = { - severity, - level, - InfoLogger::undefinedMessageOption.errorCode, - metadata.file, - atoi(std::string(metadata.line.data(), metadata.line.size()).c_str())}; - if (logger) { - logger->log(opt, *ctx, "%s", content.c_str()); + logger->log({severity, + level, + InfoLogger::undefinedMessageOption.errorCode, + std::string(metadata.file).c_str(), + atoi(std::string(metadata.line).c_str())}, + *ctx, "%s", content.c_str()); } }; }; diff --git a/GPU/GPUTracking/Definitions/GPULogging.h b/GPU/GPUTracking/Definitions/GPULogging.h index 693512b15c3c2..4ad6b70b2fd8b 100644 --- a/GPU/GPUTracking/Definitions/GPULogging.h +++ b/GPU/GPUTracking/Definitions/GPULogging.h @@ -24,6 +24,7 @@ #define GPUWarning(...) #define GPUAlarm(...) #define GPUError(...) + #define GPUCritical(...) #define GPUFatal(...) #elif defined(GPUCA_STANDALONE) && !defined(GPUCA_GPUCODE_DEVICE) && !defined(GPUCA_NO_FMT) #include @@ -38,6 +39,7 @@ fmt::fprintf(stderr, string "\n", ##__VA_ARGS__); \ } #define GPUError(...) GPUWarning(__VA_ARGS__) + #define GPUCritical(...) GPUWarning(__VA_ARGS__) #define GPUAlarm(...) GPUWarning(__VA_ARGS__) #define GPUFatal(string, ...) \ { \ @@ -64,6 +66,7 @@ } #define GPUAlarm(...) GPUWarning(__VA_ARGS__) #define GPUError(...) GPUWarning(__VA_ARGS__) + #define GPUCritical(...) GPUWarning(__VA_ARGS__) #define GPUFatal(string, ...) \ { \ fprintf(stderr, string "\n", __VA_ARGS__); \ @@ -78,6 +81,7 @@ #define GPUWarning(...) LOGF(warning, __VA_ARGS__) #define GPUAlarm(...) LOGF(alarm, __VA_ARGS__) #define GPUError(...) LOGF(error, __VA_ARGS__) + #define GPUCritical(...) LOGF(critical, __VA_ARGS__) #define GPUFatal(...) LOGF(fatal, __VA_ARGS__) #endif From 325d03b740765529e36015c88f49344436971413 Mon Sep 17 00:00:00 2001 From: Ernst Hellbar Date: Tue, 4 Mar 2025 14:35:45 +0100 Subject: [PATCH 5/5] adding error and critical severity to DPLRawParser --- Framework/Utils/include/DPLUtils/DPLRawParser.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Framework/Utils/include/DPLUtils/DPLRawParser.h b/Framework/Utils/include/DPLUtils/DPLRawParser.h index bd56b1bf7be50..e1732ef70550a 100644 --- a/Framework/Utils/include/DPLUtils/DPLRawParser.h +++ b/Framework/Utils/include/DPLUtils/DPLRawParser.h @@ -250,6 +250,10 @@ class DPLRawParser LOG(warn) << msg << (*this->mInputIterator).spec->binding << " : " << e.what(); } else if (this->mSeverity == fair::Severity::fatal) { LOG(fatal) << msg << (*this->mInputIterator).spec->binding << " : " << e.what(); + } else if (this->mSeverity == fair::Severity::critical) { + LOG(critical) << msg << (*this->mInputIterator).spec->binding << " : " << e.what(); + } else if (this->mSeverity == fair::Severity::error) { + LOG(error) << msg << (*this->mInputIterator).spec->binding << " : " << e.what(); } else if (this->mSeverity == fair::Severity::info) { LOG(info) << msg << (*this->mInputIterator).spec->binding << " : " << e.what(); } else {