Make max_line explicit for qt_color_sink

This commit is contained in:
gabime 2023-06-17 16:58:40 +03:00
parent 36eb173030
commit 9ce7295191
2 changed files with 5 additions and 4 deletions

View File

@ -431,7 +431,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
setMinimumSize(640, 480);
auto log_widget = new QTextEdit(this);
setCentralWidget(log_widget);
auto logger = spdlog::qt_color_logger_mt("qt_logger", log_widget);
int max_lines = 500; // keep widget to max 500 lines. remove old lines if needed.
auto logger = spdlog::qt_color_logger_mt("qt_logger", log_widget, max_lines);
logger->info("Some info message");
}
```

View File

@ -280,15 +280,15 @@ inline std::shared_ptr<logger> qt_logger_st(const std::string &logger_name, QObj
// log to QTextEdit with colorize output
template<typename Factory = spdlog::synchronous_factory>
inline std::shared_ptr<logger> qt_color_logger_mt(const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines=5000)
inline std::shared_ptr<logger> qt_color_logger_mt(const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines)
{
return Factory::template create<sinks::qt_color_sink_mt >(logger_name, qt_text_edit, max_lines);
}
template<typename Factory = spdlog::synchronous_factory>
inline std::shared_ptr<logger> qt_color_logger_st(const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines=5000)
inline std::shared_ptr<logger> qt_color_logger_st(const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines)
{
return Factory::template create<sinks::qt_color_sink_st >(logger_name, qt_text_edit);
return Factory::template create<sinks::qt_color_sink_st >(logger_name, qt_text_edit, max_lines);
}
} // namespace spdlog