diff --git a/opm/models/utils/start.hh b/opm/models/utils/start.hh index 0e1954758..656d950b4 100644 --- a/opm/models/utils/start.hh +++ b/opm/models/utils/start.hh @@ -36,6 +36,8 @@ #include #include +#include + #include #include @@ -226,6 +228,10 @@ static inline int start(int argc, char **argv, bool registerParams=true) #else myRank = Dune::MPIHelper::instance(argc, argv).rank(); #endif + // setting up backend for STDCOUT logger + if (myRank == 0) { + setupStreamLogging("STDOUT_LOGGER"); + } // read the initial time step and the end time Scalar endTime = Parameters::Get>(); diff --git a/opm/simulators/utils/readDeck.cpp b/opm/simulators/utils/readDeck.cpp index aeb79a7c3..d05edb1b3 100644 --- a/opm/simulators/utils/readDeck.cpp +++ b/opm/simulators/utils/readDeck.cpp @@ -515,15 +515,7 @@ Opm::setupLogging(Parallel::Communication& comm, } if (comm.rank() == 0) { - std::shared_ptr streamLog = std::make_shared(std::cout, Opm::Log::StdoutMessageTypes); - Opm::OpmLog::addBackend(stdout_log_id, streamLog); - // Set a tag limit of 10 (no category limit). Will later in - // the run be replaced by calling setupMessageLimiter(), after - // the deck is read and the (possibly user-set) category - // limits are known. - streamLog->setMessageLimiter(std::make_shared(10)); - bool use_color_coding = OpmLog::stdoutIsTerminal(); - streamLog->setMessageFormatter(std::make_shared(use_color_coding)); + setupStreamLogging(stdout_log_id); } return output; @@ -664,3 +656,16 @@ std::unique_ptr Opm::setupParseContext(const bool strictParsi return parseContext; } + +void Opm::setupStreamLogging(const std::string& stdout_log_id) +{ + std::shared_ptr streamLog = std::make_shared(std::cout, Opm::Log::StdoutMessageTypes); + Opm::OpmLog::addBackend(stdout_log_id, streamLog); + // Set a tag limit of 10 (no category limit). Will later in + // the run be replaced by calling setupMessageLimiter(), after + // the deck is read and the (possibly user-set) category + // limits are known. + streamLog->setMessageLimiter(std::make_shared(10)); + const bool use_color_coding = OpmLog::stdoutIsTerminal(); + streamLog->setMessageFormatter(std::make_shared(use_color_coding)); +} diff --git a/opm/simulators/utils/readDeck.hpp b/opm/simulators/utils/readDeck.hpp index 3c517b5ef..3be4ad036 100644 --- a/opm/simulators/utils/readDeck.hpp +++ b/opm/simulators/utils/readDeck.hpp @@ -67,6 +67,9 @@ prepareResultOutputDirectory(const std::string& baseName, const std::filesystem: std::unique_ptr setupParseContext(const bool exitOnAllErrors); +// Setup the OpmLog backends for screen output +void setupStreamLogging(const std::string& stdout_log_id); + // Setup the OpmLog backends FileOutputMode setupLogging(Parallel::Communication& comm,