diff options
author | liamwhite <liamwhite@users.noreply.github.com> | 2023-12-26 11:46:04 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-26 11:46:04 -0500 |
commit | 1559984f77c4cf7474a8f806046b709576e4e439 (patch) | |
tree | 670b041b44aeff91afb8fce0e0e0bb288f86f326 /src/common/logging/backend.cpp | |
parent | 467ac4fdfeb501a71545e9274a964c4e59e767ee (diff) | |
parent | 4f569fd568590b43cd8d924a6abf3c13632a098a (diff) |
Merge pull request #12471 from FearlessTobi/port-7146
Port citra-emu/citra#7146: "assert/logging: Stop the logging thread and flush the backends before crashing"
Diffstat (limited to 'src/common/logging/backend.cpp')
-rw-r--r-- | src/common/logging/backend.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index d4f27197c..7a267f8c0 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -208,6 +208,10 @@ public: instance->StartBackendThread(); } + static void Stop() { + instance->StopBackendThread(); + } + Impl(const Impl&) = delete; Impl& operator=(const Impl&) = delete; @@ -259,6 +263,15 @@ private: }); } + void StopBackendThread() { + backend_thread.request_stop(); + if (backend_thread.joinable()) { + backend_thread.join(); + } + + ForEachBackend([](Backend& backend) { backend.Flush(); }); + } + Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr, const char* function, std::string&& message) const { using std::chrono::duration_cast; @@ -313,6 +326,10 @@ void Start() { Impl::Start(); } +void Stop() { + Impl::Stop(); +} + void DisableLoggingInTests() { initialization_in_progress_suppress_logging = true; } |