diff --git a/include/spdlog/sinks/qt_sinks.h b/include/spdlog/sinks/qt_sinks.h index a8abb62d..25b2aae9 100644 --- a/include/spdlog/sinks/qt_sinks.h +++ b/include/spdlog/sinks/qt_sinks.h @@ -13,7 +13,6 @@ #include "spdlog/details/synchronous_factory.h" #include "spdlog/sinks/base_sink.h" -#include #include #include @@ -25,12 +24,8 @@ namespace sinks { template class qt_sink : public base_sink { public: qt_sink(QObject *qt_object = nullptr, const std::string &meta_method = "") { - if (qt_object != nullptr) { qt_object_ = qt_object; meta_method_ = meta_method; - } else { - throw spdlog_ex("Error opening qt sink"); - } } ~qt_sink() { flush_(); } @@ -60,25 +55,39 @@ using qt_sink_st = qt_sink; // // Factory functions // -template +template inline std::shared_ptr -qt_logger_mt(const std::string &logger_name, T *qt_object = nullptr, const std::string &meta_method = "") { - std::string meta_method_ = meta_method; - if (std::is_base_of::value) - meta_method_ = "append"; - else if (std::is_same::value) - meta_method_ = "appendPlainText"; - return Factory::template create(logger_name, qt_object, meta_method_); +qt_logger_mt(const std::string &logger_name, QTextEdit* qt_object, const std::string &meta_method = "append") { + return Factory::template create(logger_name, qt_object, meta_method); } -template +template inline std::shared_ptr -qt_logger_st(const std::string &logger_name, T *qt_object = nullptr, const std::string &meta_method = "") { - std::string meta_method_ = meta_method; - if (std::is_base_of::value) - meta_method_ = "append"; - else if (std::is_same::value) - meta_method_ = "appendPlainText"; - return Factory::template create(logger_name, qt_object, meta_method_); +qt_logger_st(const std::string &logger_name, QTextEdit* qt_object, const std::string &meta_method = "append") { + return Factory::template create(logger_name, qt_object, meta_method); +} + +template +inline std::shared_ptr +qt_logger_mt(const std::string &logger_name, QPlainTextEdit* qt_object , const std::string &meta_method = "appendPlainText") { + return Factory::template create(logger_name, qt_object, meta_method); +} + +template +inline std::shared_ptr +qt_logger_st(const std::string &logger_name, QPlainTextEdit* qt_object, const std::string &meta_method = "appendPlainText") { + return Factory::template create(logger_name, qt_object, meta_method); +} + +template +inline std::shared_ptr +qt_logger_mt(const std::string &logger_name, QObject* qt_object, const std::string &meta_method) { + return Factory::template create(logger_name, qt_object, meta_method); +} + +template +inline std::shared_ptr +qt_logger_st(const std::string &logger_name, QObject* qt_object, const std::string &meta_method) { + return Factory::template create(logger_name, qt_object, meta_method); } } // namespace spdlog