summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2023-12-26 17:46:04 +0100
committerGitHub <noreply@github.com>2023-12-26 17:46:04 +0100
commit1559984f77c4cf7474a8f806046b709576e4e439 (patch)
tree670b041b44aeff91afb8fce0e0e0bb288f86f326
parentMerge pull request #12472 from FearlessTobi/port-7239 (diff)
parent assert/logging: Stop the logging thread and flush the backends before crashing (diff)
downloadyuzu-1559984f77c4cf7474a8f806046b709576e4e439.tar
yuzu-1559984f77c4cf7474a8f806046b709576e4e439.tar.gz
yuzu-1559984f77c4cf7474a8f806046b709576e4e439.tar.bz2
yuzu-1559984f77c4cf7474a8f806046b709576e4e439.tar.lz
yuzu-1559984f77c4cf7474a8f806046b709576e4e439.tar.xz
yuzu-1559984f77c4cf7474a8f806046b709576e4e439.tar.zst
yuzu-1559984f77c4cf7474a8f806046b709576e4e439.zip
Diffstat (limited to '')
-rw-r--r--src/common/assert.cpp3
-rw-r--r--src/common/logging/backend.cpp17
-rw-r--r--src/common/logging/backend.h3
3 files changed, 23 insertions, 0 deletions
diff --git a/src/common/assert.cpp b/src/common/assert.cpp
index 6026b7dc2..e2c2cade3 100644
--- a/src/common/assert.cpp
+++ b/src/common/assert.cpp
@@ -3,16 +3,19 @@
#include "common/assert.h"
#include "common/common_funcs.h"
+#include "common/logging/backend.h"
#include "common/settings.h"
void assert_fail_impl() {
if (Settings::values.use_debug_asserts) {
+ Common::Log::Stop();
Crash();
}
}
[[noreturn]] void unreachable_impl() {
+ Common::Log::Stop();
Crash();
throw std::runtime_error("Unreachable code");
}
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;
}
diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h
index 12e5e2498..2a9926e9e 100644
--- a/src/common/logging/backend.h
+++ b/src/common/logging/backend.h
@@ -14,6 +14,9 @@ void Initialize();
void Start();
+/// Explicitly stops the logger thread and flushes the buffers
+void Stop();
+
void DisableLoggingInTests();
/**