summaryrefslogtreecommitdiff
path: root/src/common/logging
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/logging')
-rw-r--r--src/common/logging/backend.cpp18
-rw-r--r--src/common/logging/filter.cpp1
-rw-r--r--src/common/logging/types.h1
3 files changed, 7 insertions, 13 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index c51c05b28..4a2462ec4 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -218,19 +218,17 @@ private:
218 Impl(const std::filesystem::path& file_backend_filename, const Filter& filter_) 218 Impl(const std::filesystem::path& file_backend_filename, const Filter& filter_)
219 : filter{filter_}, file_backend{file_backend_filename} {} 219 : filter{filter_}, file_backend{file_backend_filename} {}
220 220
221 ~Impl() { 221 ~Impl() = default;
222 StopBackendThread();
223 }
224 222
225 void StartBackendThread() { 223 void StartBackendThread() {
226 backend_thread = std::thread([this] { 224 backend_thread = std::jthread([this](std::stop_token stop_token) {
227 Common::SetCurrentThreadName("yuzu:Log"); 225 Common::SetCurrentThreadName("yuzu:Log");
228 Entry entry; 226 Entry entry;
229 const auto write_logs = [this, &entry]() { 227 const auto write_logs = [this, &entry]() {
230 ForEachBackend([&entry](Backend& backend) { backend.Write(entry); }); 228 ForEachBackend([&entry](Backend& backend) { backend.Write(entry); });
231 }; 229 };
232 while (!stop.stop_requested()) { 230 while (!stop_token.stop_requested()) {
233 entry = message_queue.PopWait(stop.get_token()); 231 entry = message_queue.PopWait(stop_token);
234 if (entry.filename != nullptr) { 232 if (entry.filename != nullptr) {
235 write_logs(); 233 write_logs();
236 } 234 }
@@ -244,11 +242,6 @@ private:
244 }); 242 });
245 } 243 }
246 244
247 void StopBackendThread() {
248 stop.request_stop();
249 backend_thread.join();
250 }
251
252 Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr, 245 Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr,
253 const char* function, std::string&& message) const { 246 const char* function, std::string&& message) const {
254 using std::chrono::duration_cast; 247 using std::chrono::duration_cast;
@@ -283,10 +276,9 @@ private:
283 ColorConsoleBackend color_console_backend{}; 276 ColorConsoleBackend color_console_backend{};
284 FileBackend file_backend; 277 FileBackend file_backend;
285 278
286 std::stop_source stop;
287 std::thread backend_thread;
288 MPSCQueue<Entry, true> message_queue{}; 279 MPSCQueue<Entry, true> message_queue{};
289 std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()}; 280 std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()};
281 std::jthread backend_thread;
290}; 282};
291} // namespace 283} // namespace
292 284
diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp
index b898a652c..4afc1369a 100644
--- a/src/common/logging/filter.cpp
+++ b/src/common/logging/filter.cpp
@@ -108,6 +108,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
108 SUB(Service, Migration) \ 108 SUB(Service, Migration) \
109 SUB(Service, Mii) \ 109 SUB(Service, Mii) \
110 SUB(Service, MM) \ 110 SUB(Service, MM) \
111 SUB(Service, MNPP) \
111 SUB(Service, NCM) \ 112 SUB(Service, NCM) \
112 SUB(Service, NFC) \ 113 SUB(Service, NFC) \
113 SUB(Service, NFP) \ 114 SUB(Service, NFP) \
diff --git a/src/common/logging/types.h b/src/common/logging/types.h
index 9ed0c7ad6..2b6e4daa7 100644
--- a/src/common/logging/types.h
+++ b/src/common/logging/types.h
@@ -76,6 +76,7 @@ enum class Class : u8 {
76 Service_Migration, ///< The migration service 76 Service_Migration, ///< The migration service
77 Service_Mii, ///< The Mii service 77 Service_Mii, ///< The Mii service
78 Service_MM, ///< The MM (Multimedia) service 78 Service_MM, ///< The MM (Multimedia) service
79 Service_MNPP, ///< The MNPP service
79 Service_NCM, ///< The NCM service 80 Service_NCM, ///< The NCM service
80 Service_NFC, ///< The NFC (Near-field communication) service 81 Service_NFC, ///< The NFC (Near-field communication) service
81 Service_NFP, ///< The NFP service 82 Service_NFP, ///< The NFP service