[APP] Flush log & save config on quick exit

This commit is contained in:
Adrian
2026-05-14 19:16:46 +01:00
committed by Radosław Gliński
parent 4c396fe611
commit a261b83def
5 changed files with 28 additions and 1 deletions

View File

@@ -65,6 +65,7 @@ DEFINE_int32(
namespace dp = disruptorplus;
using namespace xe::literals;
using namespace std::chrono_literals;
namespace xe {
@@ -240,9 +241,15 @@ class Logger {
sinks_.push_back(std::move(sink));
}
void FlushAllSinks() {
for (const auto& sink : sinks_) {
sink->Flush();
}
}
private:
static constexpr size_t kBufferSize = 8_MiB;
uint8_t buffer_[kBufferSize];
uint8_t buffer_[kBufferSize] = {};
static constexpr size_t kBlockSize = 256;
static constexpr size_t kBlockCount = kBufferSize / kBlockSize;
@@ -468,6 +475,15 @@ void ShutdownLogging() {
memory::AlignedFree(logger);
}
void FlushLog() {
if (!logger_) {
return;
}
xe::threading::Sleep(10ms);
logger_->FlushAllSinks();
}
static int g_saved_loglevel = static_cast<int>(LogLevel::Disabled);
void logging::ToggleLogLevel() {
auto swap = g_saved_loglevel;

View File

@@ -75,6 +75,7 @@ class DebugPrintLogSink final : public LogSink {
// Must be called on startup.
void InitializeLogging(const std::string_view app_name);
void ShutdownLogging();
void FlushLog();
namespace logging {