diff options
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(); } |