diff --git a/xs/src/libslic3r/Log.cpp b/xs/src/libslic3r/Log.cpp index fe2a265b7..5313b4cbf 100644 --- a/xs/src/libslic3r/Log.cpp +++ b/xs/src/libslic3r/Log.cpp @@ -52,9 +52,10 @@ void _Log::debug(const std::string& topic, const std::wstring& message) { this-> void _Log::fatal_error(const std::string& topic, const std::string& message) { this->fatal_error(topic) << message << std::endl; } -std::ostream& _Log::fatal_error(const std::string& topic) { +std::ostream& _Log::fatal_error(const std::string& topic, bool multiline) { if (this->_has_log_level(log_t::FERR) && this->_has_topic(topic)) { - _out << topic << std::setfill(' ') << std::setw(6) << "FERR" << ": "; + if (!multiline) + _out << topic << std::setfill(' ') << std::setw(6) << "FERR" << ": "; return _out; } return null_log; @@ -63,9 +64,10 @@ std::ostream& _Log::fatal_error(const std::string& topic) { void _Log::error(const std::string& topic, const std::string& message) { this->error(topic) << message << std::endl; } -std::ostream& _Log::error(const std::string& topic) { +std::ostream& _Log::error(const std::string& topic, bool multiline) { if (this->_has_log_level(log_t::ERR) && this->_has_topic(topic)) { - _out << topic << std::setfill(' ') << std::setw(6) << "ERR" << ": "; + if (!multiline) + _out << topic << std::setfill(' ') << std::setw(6) << "ERR" << ": "; return _out; } return null_log; @@ -75,9 +77,10 @@ void _Log::info(const std::string& topic, const std::string& message) { this->info(topic) << message << std::endl; } -std::ostream& _Log::info(const std::string& topic) { +std::ostream& _Log::info(const std::string& topic, bool multiline) { if (this->_has_log_level(log_t::INFO) && this->_has_topic(topic)) { - _out << topic << std::setfill(' ') << std::setw(6) << "INFO" << ": "; + if (!multiline) + _out << topic << std::setfill(' ') << std::setw(6) << "INFO" << ": "; return _out; } return null_log; @@ -87,9 +90,10 @@ void _Log::warn(const std::string& topic, const std::string& message) { this->warn(topic) << message << std::endl; } -std::ostream& _Log::warn(const std::string& topic) { +std::ostream& _Log::warn(const std::string& topic, bool multiline) { if (this->_has_log_level(log_t::WARN) && this->_has_topic(topic)) { - _out << topic << std::setfill(' ') << std::setw(6) << "WARN" << ": "; + if (!multiline) + _out << topic << std::setfill(' ') << std::setw(6) << "WARN" << ": "; return _out; } return null_log; @@ -99,9 +103,10 @@ void _Log::debug(const std::string& topic, const std::string& message) { this->debug(topic) << message << std::endl; } -std::ostream& _Log::debug(const std::string& topic) { +std::ostream& _Log::debug(const std::string& topic, bool multiline) { if (this->_has_log_level(log_t::DEBUG) && this->_has_topic(topic)) { - _out << topic << std::setfill(' ') << std::setw(6) << "DEBUG" << ": "; + if (!multiline) + _out << topic << std::setfill(' ') << std::setw(6) << "DEBUG" << ": "; return _out; } return null_log; diff --git a/xs/src/libslic3r/Log.hpp b/xs/src/libslic3r/Log.hpp index 81a42bacb..74a9eca6a 100644 --- a/xs/src/libslic3r/Log.hpp +++ b/xs/src/libslic3r/Log.hpp @@ -42,21 +42,21 @@ public: } void fatal_error(const std::string& topic, const std::string& message); void fatal_error(const std::string& topic, const std::wstring& message); - std::ostream& fatal_error(const std::string& topic); + std::ostream& fatal_error(const std::string& topic, bool multiline = false); void error(const std::string& topic, const std::string& message); void error(const std::string& topic, const std::wstring& message); - std::ostream& error(const std::string& topic); + std::ostream& error(const std::string& topic, bool multiline = false); void info(const std::string& topic, const std::string& message); void info(const std::string& topic, const std::wstring& message); - std::ostream& info(const std::string& topic); + std::ostream& info(const std::string& topic, bool multiline = false); void debug(const std::string& topic, const std::string& message); void debug(const std::string& topic, const std::wstring& message); - std::ostream& debug(const std::string& topic); + std::ostream& debug(const std::string& topic, bool multiline = false); void warn(const std::string& topic, const std::string& message); void warn(const std::string& topic, const std::wstring& message); - std::ostream& warn(const std::string& topic); + std::ostream& warn(const std::string& topic, bool multiline = false); void raw(const std::string& message); void raw(const std::wstring& message); std::ostream& raw(); @@ -159,32 +159,36 @@ public: /// Logs an error message with Slic3r. /// \param topic [in] file or heading for message + /// \param multiline [in] Is this a following part of a multline output (default False) /// \return reference to output ostream for << chaining. /// \note Developer is expected to add newlines. - static std::ostream& error(std::string topic) { - return slic3r_log->error(topic); + static std::ostream& error(std::string topic, bool multiline = false) { + return slic3r_log->error(topic, multiline); } /// Logs a debugging message with Slic3r. /// \param topic [in] file or heading for message + /// \param multiline [in] Is this a following part of a multline output (default False) /// \return reference to output ostream for << chaining. /// \note Developer is expected to add newlines. - static std::ostream& debug(std::string topic) { - return slic3r_log->debug(topic); + static std::ostream& debug(std::string topic, bool multiline = false) { + return slic3r_log->debug(topic, multiline); } /// Logs a warning message with Slic3r. /// \param topic [in] file or heading for message + /// \param multiline [in] Is this a following part of a multline output (default False) /// \return reference to output ostream for << chaining. /// \note Developer is expected to add newlines. - static std::ostream& warn(std::string topic) { - return slic3r_log->warn(topic); + static std::ostream& warn(std::string topic, bool multiline = false) { + return slic3r_log->warn(topic, multiline); } /// Logs an informational message with Slic3r. /// \param topic [in] file or heading for message + /// \param multiline [in] Is this a following part of a multline output (default False) /// \return reference to output ostream for << chaining. /// \note Developer is expected to add newlines. - static std::ostream& info(std::string topic) { - return slic3r_log->info(topic); + static std::ostream& info(std::string topic, bool multiline = false) { + return slic3r_log->info(topic, multiline); } /// Unadorned ostream output for multiline constructions.