mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-10-12 17:02:02 -05:00
Clear DeferredLogger's message container after logging.
This keeps from logging the same messages again. Also add clearMessages() method, which is useful to clear the local container after gathering into a global container (which leaves the local containers untouched).
This commit is contained in:
1 parent
9bbb0ef679
commit
32572ac2ab
3 files changed
+15
No files matched your search
@@ -86,6 +86,12 @@ namespace Opm
|
|||||||
for (const auto& m : messages_) {
|
for (const auto& m : messages_) {
|
||||||
OpmLog::addTaggedMessage(m.flag, m.tag, m.text);
|
OpmLog::addTaggedMessage(m.flag, m.tag, m.text);
|
||||||
}
|
}
|
||||||
|
messages_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeferredLogger::clearMessages()
|
||||||
|
{
|
||||||
|
messages_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
@@ -60,8 +60,13 @@ namespace Opm
|
|||||||
void debug(const std::string& message);
|
void debug(const std::string& message);
|
||||||
void note(const std::string& message);
|
void note(const std::string& message);
|
||||||
|
|
||||||
|
/// Log all messages to the OpmLog backends,
|
||||||
|
/// and clear the message container.
|
||||||
void logMessages();
|
void logMessages();
|
||||||
|
|
||||||
|
/// Clear the message container without logging them.
|
||||||
|
void clearMessages();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Message> messages_;
|
std::vector<Message> messages_;
|
||||||
friend Opm::DeferredLogger gatherDeferredLogger(const Opm::DeferredLogger& local_deferredlogger);
|
friend Opm::DeferredLogger gatherDeferredLogger(const Opm::DeferredLogger& local_deferredlogger);
|
||||||
|
|||||||
@@ -63,6 +63,10 @@ inline void logAndCheckForExceptionsAndThrow(Opm::DeferredLogger& deferred_logge
|
|||||||
if (terminal_output) {
|
if (terminal_output) {
|
||||||
global_deferredLogger.logMessages();
|
global_deferredLogger.logMessages();
|
||||||
}
|
}
|
||||||
|
// Now that all messages have been logged, they are automatically
|
||||||
|
// cleared from the global logger, but we must also clear them
|
||||||
|
// from the local logger.
|
||||||
|
deferred_logger.clearMessages();
|
||||||
const auto& cc = Dune::MPIHelper::getCollectiveCommunication();
|
const auto& cc = Dune::MPIHelper::getCollectiveCommunication();
|
||||||
if (cc.max(exception_thrown) == 1) {
|
if (cc.max(exception_thrown) == 1) {
|
||||||
throw std::logic_error(message);
|
throw std::logic_error(message);
|
||||||
|
|||||||
Reference in new issue
Block a user