qt_sink: add some warning on its usage

pull/2753/head
Benoit FANCHON 2 years ago
parent 76fb40d954
commit 712f7f9db2

@ -25,6 +25,8 @@ template<typename Mutex>
class qt_sink : public base_sink<Mutex>
{
public:
// Warning: qt_sink won't be notified if the target QObject is destroyed.
// If the object's lifetime can be shorter than the logger's one, you should provide some permanent object and then use a standard signal/slot.
qt_sink(QObject *qt_object, const std::string &meta_method)
{
qt_object_ = qt_object;
@ -62,18 +64,24 @@ using qt_sink_st = qt_sink<spdlog::details::null_mutex>;
//
// Factory functions
//
// Warning: the qt_sink won't be notified if the target widget is destroyed.
// If the widget's lifetime can be shorter than the logger's one, you should provide some permanent QObject and then use a standard signal/slot.
template<typename Factory = spdlog::synchronous_factory>
inline std::shared_ptr<logger> qt_logger_mt(const std::string &logger_name, QTextEdit *qt_object, const std::string &meta_method = "append")
{
return Factory::template create<sinks::qt_sink_mt>(logger_name, qt_object, meta_method);
}
// Warning: the qt_sink won't be notified if the target widget is destroyed.
// If the widget's lifetime can be shorter than the logger's one, you should provide some permanent QObject and then use a standard signal/slot.
template<typename Factory = spdlog::synchronous_factory>
inline std::shared_ptr<logger> qt_logger_st(const std::string &logger_name, QTextEdit *qt_object, const std::string &meta_method = "append")
{
return Factory::template create<sinks::qt_sink_st>(logger_name, qt_object, meta_method);
}
// Warning: the qt_sink won't be notified if the target QObject is destroyed.
// If the object's lifetime can be shorter than the logger's one, you should provide some permanent QObject and then use a standard signal/slot.
template<typename Factory = spdlog::synchronous_factory>
inline std::shared_ptr<logger> qt_logger_mt(
const std::string &logger_name, QPlainTextEdit *qt_object, const std::string &meta_method = "appendPlainText")
@ -81,6 +89,8 @@ inline std::shared_ptr<logger> qt_logger_mt(
return Factory::template create<sinks::qt_sink_mt>(logger_name, qt_object, meta_method);
}
// Warning: the qt_sink won't be notified if the target widget is destroyed.
// If the widget's lifetime can be shorter than the logger's one, you should provide some permanent QObject and then use a standard signal/slot.
template<typename Factory = spdlog::synchronous_factory>
inline std::shared_ptr<logger> qt_logger_st(
const std::string &logger_name, QPlainTextEdit *qt_object, const std::string &meta_method = "appendPlainText")
@ -88,12 +98,16 @@ inline std::shared_ptr<logger> qt_logger_st(
return Factory::template create<sinks::qt_sink_st>(logger_name, qt_object, meta_method);
}
// Warning: the qt_sink won't be notified if the target QObject is destroyed.
// If the objet's lifetime can be shorter than the logger's one, you should provide some permanent QObject and then use a standard signal/slot.
template<typename Factory = spdlog::synchronous_factory>
inline std::shared_ptr<logger> qt_logger_mt(const std::string &logger_name, QObject *qt_object, const std::string &meta_method)
{
return Factory::template create<sinks::qt_sink_mt>(logger_name, qt_object, meta_method);
}
// Warning: the qt_sink won't be notified if the target QObject is destroyed.
// If the objet's lifetime can be shorter than the logger's one, you should provide some permanent QObject and then use a standard signal/slot.
template<typename Factory = spdlog::synchronous_factory>
inline std::shared_ptr<logger> qt_logger_st(const std::string &logger_name, QObject *qt_object, const std::string &meta_method)
{

Loading…
Cancel
Save