From 79a1239e3213eee101834ea569ef7cd2f8b3ae42 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sun, 7 Jun 2020 21:17:23 -0500 Subject: [PATCH] Help Slic3r::_Log out by adding methods to cover const char* and const wchar_t* (so our tests pass and things don't break when passed string literals). --- xs/src/libslic3r/Log.cpp | 68 ++++++++++++++++++++++++++++++++++++++++ xs/src/libslic3r/Log.hpp | 18 +++++++++++ 2 files changed, 86 insertions(+) diff --git a/xs/src/libslic3r/Log.cpp b/xs/src/libslic3r/Log.cpp index 5313b4cbf..8cde37fc4 100644 --- a/xs/src/libslic3r/Log.cpp +++ b/xs/src/libslic3r/Log.cpp @@ -49,9 +49,21 @@ void _Log::warn(const std::string& topic, const std::wstring& message) { this->w void _Log::info(const std::string& topic, const std::wstring& message) { this->info(topic, boost::locale::conv::utf_to_utf(message)); } void _Log::debug(const std::string& topic, const std::wstring& message) { this->debug(topic, boost::locale::conv::utf_to_utf(message)); } +void _Log::fatal_error(const char topic[], const char message[]) { + this->fatal_error(std::string(topic), std::string(message)); +} + +void _Log::fatal_error(const char topic[], const wchar_t message[]) { + this->fatal_error(std::string(topic), std::wstring(message)); +} + 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 char topic[], bool multiline) { + return this->fatal_error(std::string(topic), multiline); +} std::ostream& _Log::fatal_error(const std::string& topic, bool multiline) { if (this->_has_log_level(log_t::FERR) && this->_has_topic(topic)) { if (!multiline) @@ -61,9 +73,20 @@ std::ostream& _Log::fatal_error(const std::string& topic, bool multiline) { return null_log; } +void _Log::error(const char topic[], const char message[]) { + this->error(std::string(topic), std::string(message)); +} + +void _Log::error(const char topic[], const wchar_t message[]) { + this->error(std::string(topic), std::wstring(message)); +} + void _Log::error(const std::string& topic, const std::string& message) { this->error(topic) << message << std::endl; } +std::ostream& _Log::error(const char topic[], bool multiline) { + return this->error(std::string(topic), multiline); +} std::ostream& _Log::error(const std::string& topic, bool multiline) { if (this->_has_log_level(log_t::ERR) && this->_has_topic(topic)) { if (!multiline) @@ -73,10 +96,23 @@ std::ostream& _Log::error(const std::string& topic, bool multiline) { return null_log; } + void _Log::info(const std::string& topic, const std::string& message) { this->info(topic) << message << std::endl; } +void _Log::info(const char topic[], const wchar_t message[]) { + this->info(std::string(topic), std::wstring(message)); +} + +void _Log::info(const char topic[], const char message[]) { + this->info(std::string(topic), std::string(message)); +} + +std::ostream& _Log::info(const char topic[], bool multiline) { + return this->info(std::string(topic), multiline); +} + std::ostream& _Log::info(const std::string& topic, bool multiline) { if (this->_has_log_level(log_t::INFO) && this->_has_topic(topic)) { if (!multiline) @@ -86,10 +122,22 @@ std::ostream& _Log::info(const std::string& topic, bool multiline) { return null_log; } +void _Log::warn(const char topic[], const char message[]) { + this->warn(std::string(topic), std::string(message)); +} + +void _Log::warn(const char topic[], const wchar_t message[]) { + this->warn(std::string(topic), std::wstring(message)); +} + void _Log::warn(const std::string& topic, const std::string& message) { this->warn(topic) << message << std::endl; } +std::ostream& _Log::warn(const char topic[], bool multiline) { + return this->warn(std::string(topic), multiline); +} + std::ostream& _Log::warn(const std::string& topic, bool multiline) { if (this->_has_log_level(log_t::WARN) && this->_has_topic(topic)) { if (!multiline) @@ -99,10 +147,22 @@ std::ostream& _Log::warn(const std::string& topic, bool multiline) { return null_log; } +void _Log::debug(const char topic[], const char message[]) { + this->debug(std::string(topic), std::string(message)); +} + +void _Log::debug(const char topic[], const wchar_t message[]) { + this->debug(std::string(topic), std::wstring(message)); +} + void _Log::debug(const std::string& topic, const std::string& message) { this->debug(topic) << message << std::endl; } +std::ostream& _Log::debug(const char topic[], bool multiline) { + return this->debug(std::string(topic), multiline); +} + std::ostream& _Log::debug(const std::string& topic, bool multiline) { if (this->_has_log_level(log_t::DEBUG) && this->_has_topic(topic)) { if (!multiline) @@ -112,6 +172,14 @@ std::ostream& _Log::debug(const std::string& topic, bool multiline) { return null_log; } +void _Log::raw(const char message[]) { + this->raw(std::string(message)); +} + +void _Log::raw(const wchar_t message[]) { + this->raw(std::wstring(message)); +} + void _Log::raw(const std::string& message) { this->raw() << message << std::endl; } diff --git a/xs/src/libslic3r/Log.hpp b/xs/src/libslic3r/Log.hpp index 74a9eca6a..6a7ed19ba 100644 --- a/xs/src/libslic3r/Log.hpp +++ b/xs/src/libslic3r/Log.hpp @@ -40,23 +40,41 @@ public: tmp->set_level(log_t::WARN); return tmp; } + void fatal_error(const char topic[], const char message[]); + void fatal_error(const char topic[], const wchar_t message[]); 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, bool multiline = false); + std::ostream& fatal_error(const char topic[], bool multiline = false); + void error(const char topic[], const char message[]); + void error(const char topic[], const wchar_t message[]); 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, bool multiline = false); + std::ostream& error(const char topic[], bool multiline = false); void info(const std::string& topic, const std::string& message); void info(const std::string& topic, const std::wstring& message); + void info(const char topic[], const char message[]); + void info(const char topic[], const wchar_t message[]); std::ostream& info(const std::string& topic, bool multiline = false); + std::ostream& info(const char topic[], bool multiline = false); + void debug(const char topic[], const char message[]); + void debug(const char topic[], const wchar_t message[]); 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, bool multiline = false); + std::ostream& debug(const char topic[], bool multiline = false); + void warn(const char topic[], const char message[]); + void warn(const char topic[], const wchar_t message[]); 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, bool multiline = false); + std::ostream& warn(const char topic[], bool multiline = false); + + void raw(const char message[]); + void raw(const wchar_t message[]); void raw(const std::string& message); void raw(const std::wstring& message); std::ostream& raw();