Skip to content

Commit

Permalink
fix: flush spdlog messages also when logging to stderr (KDAB#142)
Browse files Browse the repository at this point in the history
The existing code was only enabling flush when logs are redirected to files.
Without this, the relative order of the debug output from qWarnings() and from Message.log() wasn't preserved, making debugging difficult.
  • Loading branch information
smnppKDAB authored Aug 7, 2024
1 parent 77af0b7 commit 3831bd6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/knutcore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ void KnutCore::initialize(Settings::Mode mode)
new ScriptManager(this);
if (Core::Settings::instance()->value<bool>(Core::Settings::SaveLogsToFile))
initializeMultiSinkLogger();
// auto flush when "info" or higher message is logged.
spdlog::flush_on(spdlog::level::info);
m_initialized = true;
}

Expand All @@ -207,8 +209,6 @@ void KnutCore::initializeMultiSinkLogger()
Core::Settings::instance()->logFilePath().toStdString(), SIZE_MAX, max_files, rotate_on_open);
auto logger = spdlog::default_logger();
logger->sinks().push_back(fileSink);
// auto flush when "info" or higher message is logged.
spdlog::flush_on(spdlog::level::info);
}

} // namespace Core

0 comments on commit 3831bd6

Please sign in to comment.