From 8b54b1309da903ee2613a495dd9fcd3de006a045 Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Thu, 2 Dec 2021 16:32:34 -0500 Subject: [PATCH] make adiosLog only print the same message once, and throw exceptions regardless printing or not --- source/adios2/helper/adiosLog.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/source/adios2/helper/adiosLog.cpp b/source/adios2/helper/adiosLog.cpp index d5185a5b29..174fae13db 100644 --- a/source/adios2/helper/adiosLog.cpp +++ b/source/adios2/helper/adiosLog.cpp @@ -13,6 +13,7 @@ #include #include #include +#include namespace adios2 { @@ -26,6 +27,8 @@ std::string errorColor = "\033[1;31m"; std::string exceptionColor = "\033[1;34m"; std::string defaultColor = "\033[0m"; +std::unordered_set messages; + void Log(const std::string &component, const std::string &source, const std::string &activity, const std::string &message, const LogMode mode) @@ -47,18 +50,25 @@ void Log(const std::string &component, const std::string &source, const int verbosity, const LogMode mode) { - if (mode != LogMode::EXCEPTION) + // don't print if + // 1. logRank does not meet commRank, or + // 2. priority does not meet verbosity, or + // 3. the same messaage has been already printed + if ((logRank >= 0 && commRank >= 0 && logRank != commRank) || + priority > verbosity || messages.find(message) != messages.end()) { - if (logRank >= 0 && commRank >= 0 && logRank != commRank) + if (mode == LogMode::EXCEPTION) { - return; + throw(message); } - if (priority > verbosity) + else { return; } } + messages.insert(message); + std::stringstream m; auto timeNow =