From f489281e11711169f7a932d1e67a72fca07f0b60 Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Wed, 1 Sep 2021 14:46:23 +0200 Subject: [PATCH] LOG: Add the flushLogSink utility method to help with the use of the log system --- src/Lib/Log.hh | 5 ++++- src/VivyApplication.cc | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Lib/Log.hh b/src/Lib/Log.hh index dcb33f6b..b40bac3a 100644 --- a/src/Lib/Log.hh +++ b/src/Lib/Log.hh @@ -10,7 +10,10 @@ #define VIVY_LOG_ERR(log) VIVY_LOG_WITH_LEVEL(log, LogLevel::Error) #define VIVY_LOG_FATAL(log) VIVY_LOG_WITH_LEVEL(log, LogLevel::Critical) -#define VIVY_DCL_LOG_SINK(sink) std::shared_ptr<LogSink> sink{ LogSink::newSink() }; +#define VIVY_DCL_LOG_SINK(sink) \ + std::shared_ptr<LogSink> sink{ LogSink::newSink() }; \ + void flushLogSink() const noexcept { sink->flush(); } + #define VIVY_DCL_LOG_DISPATCH(sink, name, dispatch) \ std::shared_ptr<dispatch> name{ sink->newDispatcher<dispatch>() }; diff --git a/src/VivyApplication.cc b/src/VivyApplication.cc index b312b27c..2020a97b 100644 --- a/src/VivyApplication.cc +++ b/src/VivyApplication.cc @@ -28,6 +28,8 @@ VivyApplication::setTheme(Theme theme) noexcept setStyleSheet(stylesheetStream.readAll()); logInfo() << "Theme set using " << sheet; } + + flushLogSink(); } int @@ -62,6 +64,7 @@ VivyApplication::exec() noexcept logInfo() << "Entering the main event loop"; // Main loop + flushLogSink(); return QApplication::exec(); } -- GitLab