From 9ce729519174a9acc79ae0bdb9615b8cc9fdf53e Mon Sep 17 00:00:00 2001 From: gabime Date: Sat, 17 Jun 2023 16:58:40 +0300 Subject: [PATCH] Make max_line explicit for qt_color_sink --- README.md | 3 ++- include/spdlog/sinks/qt_sinks.h | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 45537d72..f793e90f 100644 --- a/README.md +++ b/README.md @@ -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"); } ``` diff --git a/include/spdlog/sinks/qt_sinks.h b/include/spdlog/sinks/qt_sinks.h index b626d537..6c0c7c24 100644 --- a/include/spdlog/sinks/qt_sinks.h +++ b/include/spdlog/sinks/qt_sinks.h @@ -280,15 +280,15 @@ inline std::shared_ptr qt_logger_st(const std::string &logger_name, QObj // log to QTextEdit with colorize output template -inline std::shared_ptr qt_color_logger_mt(const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines=5000) +inline std::shared_ptr qt_color_logger_mt(const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines) { return Factory::template create(logger_name, qt_text_edit, max_lines); } template -inline std::shared_ptr qt_color_logger_st(const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines=5000) +inline std::shared_ptr qt_color_logger_st(const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines) { - return Factory::template create(logger_name, qt_text_edit); + return Factory::template create(logger_name, qt_text_edit, max_lines); } } // namespace spdlog