[APP] Flush log & save config on quick exit
This commit is contained in:
@@ -574,6 +574,9 @@ void EmulatorApp::OnDestroy() {
|
|||||||
|
|
||||||
// TODO(DrChat): Remove this code and do a proper exit.
|
// TODO(DrChat): Remove this code and do a proper exit.
|
||||||
XELOGI("Cheap-skate exit!");
|
XELOGI("Cheap-skate exit!");
|
||||||
|
|
||||||
|
xe::FlushLog();
|
||||||
|
|
||||||
std::quick_exit(EXIT_SUCCESS);
|
std::quick_exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ DEFINE_int32(
|
|||||||
|
|
||||||
namespace dp = disruptorplus;
|
namespace dp = disruptorplus;
|
||||||
using namespace xe::literals;
|
using namespace xe::literals;
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
@@ -240,9 +241,15 @@ class Logger {
|
|||||||
sinks_.push_back(std::move(sink));
|
sinks_.push_back(std::move(sink));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FlushAllSinks() {
|
||||||
|
for (const auto& sink : sinks_) {
|
||||||
|
sink->Flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr size_t kBufferSize = 8_MiB;
|
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 kBlockSize = 256;
|
||||||
static constexpr size_t kBlockCount = kBufferSize / kBlockSize;
|
static constexpr size_t kBlockCount = kBufferSize / kBlockSize;
|
||||||
@@ -468,6 +475,15 @@ void ShutdownLogging() {
|
|||||||
memory::AlignedFree(logger);
|
memory::AlignedFree(logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FlushLog() {
|
||||||
|
if (!logger_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
xe::threading::Sleep(10ms);
|
||||||
|
logger_->FlushAllSinks();
|
||||||
|
}
|
||||||
|
|
||||||
static int g_saved_loglevel = static_cast<int>(LogLevel::Disabled);
|
static int g_saved_loglevel = static_cast<int>(LogLevel::Disabled);
|
||||||
void logging::ToggleLogLevel() {
|
void logging::ToggleLogLevel() {
|
||||||
auto swap = g_saved_loglevel;
|
auto swap = g_saved_loglevel;
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ class DebugPrintLogSink final : public LogSink {
|
|||||||
// Must be called on startup.
|
// Must be called on startup.
|
||||||
void InitializeLogging(const std::string_view app_name);
|
void InitializeLogging(const std::string_view app_name);
|
||||||
void ShutdownLogging();
|
void ShutdownLogging();
|
||||||
|
void FlushLog();
|
||||||
|
|
||||||
namespace logging {
|
namespace logging {
|
||||||
|
|
||||||
|
|||||||
@@ -286,6 +286,9 @@ void GraphicsSystem::OnHostGpuLossFromAnyThread(
|
|||||||
if (host_gpu_loss_reported_.test_and_set(std::memory_order_relaxed)) {
|
if (host_gpu_loss_reported_.test_and_set(std::memory_order_relaxed)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config::SaveConfig();
|
||||||
|
|
||||||
xe::FatalError("Graphics device lost (probably due to an internal error)");
|
xe::FatalError("Graphics device lost (probably due to an internal error)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "xenia/base/cvar.h"
|
#include "xenia/base/cvar.h"
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
#include "xenia/base/string_util.h"
|
#include "xenia/base/string_util.h"
|
||||||
|
#include "xenia/config.h"
|
||||||
#include "xenia/kernel/kernel_state.h"
|
#include "xenia/kernel/kernel_state.h"
|
||||||
#include "xenia/kernel/title_id_utils.h"
|
#include "xenia/kernel/title_id_utils.h"
|
||||||
#include "xenia/kernel/user_module.h"
|
#include "xenia/kernel/user_module.h"
|
||||||
@@ -324,6 +325,9 @@ void XamLoaderLaunchTitle_entry(lpstring_t raw_name_ptr, dword_t flags) {
|
|||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config::SaveConfig();
|
||||||
|
xe::FlushLog();
|
||||||
|
|
||||||
std::quick_exit(0);
|
std::quick_exit(0);
|
||||||
}).detach();
|
}).detach();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user