diff options
author | 2022-03-08 18:38:25 +0100 | |
---|---|---|
committer | 2022-03-08 09:38:25 -0800 | |
commit | 0a64c2b8a42d766e5a893fcab2d4573b33cca74f (patch) | |
tree | 16f5979ff152251fc443f2e5ee67f929d6534228 /Source/Utils/WarnManager.cpp | |
parent | 7425721ccced342615c054ea8147fbdc484d6620 (diff) | |
download | WarpX-0a64c2b8a42d766e5a893fcab2d4573b33cca74f.tar.gz WarpX-0a64c2b8a42d766e5a893fcab2d4573b33cca74f.tar.zst WarpX-0a64c2b8a42d766e5a893fcab2d4573b33cca74f.zip |
Make error and info messages visually uniform (#2939)
* initial work to add msg formatter
* wip
* replace AMREX_ALWAYS_ASSERT_WITH_MESSAGE with WarpX equivalent
Diffstat (limited to 'Source/Utils/WarnManager.cpp')
-rw-r--r-- | Source/Utils/WarnManager.cpp | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/Source/Utils/WarnManager.cpp b/Source/Utils/WarnManager.cpp index 4e8332631..973e7ca28 100644 --- a/Source/Utils/WarnManager.cpp +++ b/Source/Utils/WarnManager.cpp @@ -8,6 +8,7 @@ #include "WarnManager.H" #include "MsgLogger/MsgLogger.H" +#include "WarpXUtil.H" #include <AMReX_ParallelDescriptor.H> @@ -201,39 +202,12 @@ WarnManager::msg_formatter( const auto prefix = "*" + std::string(tab_size, ' '); const auto prefix_length = static_cast<int>(prefix.length()); - std::stringstream ss_out; - std::stringstream ss_msg{msg}; - - std::string line; - std::string word; - - while(std::getline(ss_msg, line,'\n')){ - ss_out << prefix; + const auto wrapped_text = WarpXUtilStr::automatic_text_wrap( + msg, line_size-prefix_length); - std::stringstream ss_line{line}; - int counter = prefix_length; - - while (ss_line >> word){ - const auto wlen = static_cast<int>(word.length()); - - if(counter == prefix_length){ - ss_out << word; - counter += wlen; - } - else{ - if (counter + wlen < line_size){ - ss_out << " " << word; - counter += (wlen+1); - } - else{ - ss_out << "\n" << prefix << word; - counter = prefix_length + wlen; - } - } - } - - ss_out << '\n'; - } + std::stringstream ss_out; + for (const auto& line : wrapped_text) + ss_out << prefix << line << "\n"; return ss_out.str(); } |