summaryrefslogtreecommitdiff
path: root/src/common/logging
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/logging')
-rw-r--r--src/common/logging/backend.cpp27
-rw-r--r--src/common/logging/backend.h6
-rw-r--r--src/common/logging/filter.cpp10
-rw-r--r--src/common/logging/filter.h6
-rw-r--r--src/common/logging/formatter.h5
-rw-r--r--src/common/logging/log.h5
-rw-r--r--src/common/logging/log_entry.h5
-rw-r--r--src/common/logging/text_formatter.cpp7
-rw-r--r--src/common/logging/text_formatter.h6
-rw-r--r--src/common/logging/types.h10
10 files changed, 34 insertions, 53 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index c51c05b28..15d92505e 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -1,14 +1,11 @@
1// Copyright 2014 Citra Emulator Project 1// SPDX-FileCopyrightText: 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version 2// SPDX-License-Identifier: GPL-2.0-or-later
3// Refer to the license.txt file included.
4 3
5#include <atomic> 4#include <atomic>
6#include <chrono> 5#include <chrono>
7#include <climits> 6#include <climits>
8#include <exception>
9#include <stop_token> 7#include <stop_token>
10#include <thread> 8#include <thread>
11#include <vector>
12 9
13#include <fmt/format.h> 10#include <fmt/format.h>
14 11
@@ -218,19 +215,17 @@ private:
218 Impl(const std::filesystem::path& file_backend_filename, const Filter& filter_) 215 Impl(const std::filesystem::path& file_backend_filename, const Filter& filter_)
219 : filter{filter_}, file_backend{file_backend_filename} {} 216 : filter{filter_}, file_backend{file_backend_filename} {}
220 217
221 ~Impl() { 218 ~Impl() = default;
222 StopBackendThread();
223 }
224 219
225 void StartBackendThread() { 220 void StartBackendThread() {
226 backend_thread = std::thread([this] { 221 backend_thread = std::jthread([this](std::stop_token stop_token) {
227 Common::SetCurrentThreadName("yuzu:Log"); 222 Common::SetCurrentThreadName("Logger");
228 Entry entry; 223 Entry entry;
229 const auto write_logs = [this, &entry]() { 224 const auto write_logs = [this, &entry]() {
230 ForEachBackend([&entry](Backend& backend) { backend.Write(entry); }); 225 ForEachBackend([&entry](Backend& backend) { backend.Write(entry); });
231 }; 226 };
232 while (!stop.stop_requested()) { 227 while (!stop_token.stop_requested()) {
233 entry = message_queue.PopWait(stop.get_token()); 228 entry = message_queue.PopWait(stop_token);
234 if (entry.filename != nullptr) { 229 if (entry.filename != nullptr) {
235 write_logs(); 230 write_logs();
236 } 231 }
@@ -244,11 +239,6 @@ private:
244 }); 239 });
245 } 240 }
246 241
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, 242 Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr,
253 const char* function, std::string&& message) const { 243 const char* function, std::string&& message) const {
254 using std::chrono::duration_cast; 244 using std::chrono::duration_cast;
@@ -283,10 +273,9 @@ private:
283 ColorConsoleBackend color_console_backend{}; 273 ColorConsoleBackend color_console_backend{};
284 FileBackend file_backend; 274 FileBackend file_backend;
285 275
286 std::stop_source stop;
287 std::thread backend_thread;
288 MPSCQueue<Entry, true> message_queue{}; 276 MPSCQueue<Entry, true> message_queue{};
289 std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()}; 277 std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()};
278 std::jthread backend_thread;
290}; 279};
291} // namespace 280} // namespace
292 281
diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h
index bf785f402..12e5e2498 100644
--- a/src/common/logging/backend.h
+++ b/src/common/logging/backend.h
@@ -1,10 +1,8 @@
1// Copyright 2014 Citra Emulator Project 1// SPDX-FileCopyrightText: 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version 2// SPDX-License-Identifier: GPL-2.0-or-later
3// Refer to the license.txt file included.
4 3
5#pragma once 4#pragma once
6 5
7#include <filesystem>
8#include "common/logging/filter.h" 6#include "common/logging/filter.h"
9 7
10namespace Common::Log { 8namespace Common::Log {
diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp
index b898a652c..a959acb74 100644
--- a/src/common/logging/filter.cpp
+++ b/src/common/logging/filter.cpp
@@ -1,6 +1,5 @@
1// Copyright 2014 Citra Emulator Project 1// SPDX-FileCopyrightText: 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version 2// SPDX-License-Identifier: GPL-2.0-or-later
3// Refer to the license.txt file included.
4 3
5#include <algorithm> 4#include <algorithm>
6#include "common/logging/filter.h" 5#include "common/logging/filter.h"
@@ -101,6 +100,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
101 SUB(Service, GRC) \ 100 SUB(Service, GRC) \
102 SUB(Service, HID) \ 101 SUB(Service, HID) \
103 SUB(Service, IRS) \ 102 SUB(Service, IRS) \
103 SUB(Service, JIT) \
104 SUB(Service, LBL) \ 104 SUB(Service, LBL) \
105 SUB(Service, LDN) \ 105 SUB(Service, LDN) \
106 SUB(Service, LDR) \ 106 SUB(Service, LDR) \
@@ -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) \
@@ -118,6 +119,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
118 SUB(Service, NPNS) \ 119 SUB(Service, NPNS) \
119 SUB(Service, NS) \ 120 SUB(Service, NS) \
120 SUB(Service, NVDRV) \ 121 SUB(Service, NVDRV) \
122 SUB(Service, NVFlinger) \
121 SUB(Service, OLSC) \ 123 SUB(Service, OLSC) \
122 SUB(Service, PCIE) \ 124 SUB(Service, PCIE) \
123 SUB(Service, PCTL) \ 125 SUB(Service, PCTL) \
@@ -125,7 +127,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
125 SUB(Service, PM) \ 127 SUB(Service, PM) \
126 SUB(Service, PREPO) \ 128 SUB(Service, PREPO) \
127 SUB(Service, PSC) \ 129 SUB(Service, PSC) \
128 SUB(Service, PSM) \ 130 SUB(Service, PTM) \
129 SUB(Service, SET) \ 131 SUB(Service, SET) \
130 SUB(Service, SM) \ 132 SUB(Service, SM) \
131 SUB(Service, SPL) \ 133 SUB(Service, SPL) \
diff --git a/src/common/logging/filter.h b/src/common/logging/filter.h
index 1a3074e04..54d172cc0 100644
--- a/src/common/logging/filter.h
+++ b/src/common/logging/filter.h
@@ -1,13 +1,11 @@
1// Copyright 2014 Citra Emulator Project 1// SPDX-FileCopyrightText: 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version 2// SPDX-License-Identifier: GPL-2.0-or-later
3// Refer to the license.txt file included.
4 3
5#pragma once 4#pragma once
6 5
7#include <array> 6#include <array>
8#include <chrono> 7#include <chrono>
9#include <cstddef> 8#include <cstddef>
10#include <string_view>
11#include "common/logging/log.h" 9#include "common/logging/log.h"
12 10
13namespace Common::Log { 11namespace Common::Log {
diff --git a/src/common/logging/formatter.h b/src/common/logging/formatter.h
index 552cde75a..88e55505d 100644
--- a/src/common/logging/formatter.h
+++ b/src/common/logging/formatter.h
@@ -1,6 +1,5 @@
1// Copyright 2022 yuzu Emulator Project 1// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
2// Licensed under GPLv2 or any later version 2// SPDX-License-Identifier: GPL-2.0-or-later
3// Refer to the license.txt file included.
4 3
5#pragma once 4#pragma once
6 5
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 0c80d01ee..c00c01a9e 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -1,6 +1,5 @@
1// Copyright 2014 Citra Emulator Project 1// SPDX-FileCopyrightText: 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version 2// SPDX-License-Identifier: GPL-2.0-or-later
3// Refer to the license.txt file included.
4 3
5#pragma once 4#pragma once
6 5
diff --git a/src/common/logging/log_entry.h b/src/common/logging/log_entry.h
index b28570071..d8d7daf76 100644
--- a/src/common/logging/log_entry.h
+++ b/src/common/logging/log_entry.h
@@ -1,6 +1,5 @@
1// Copyright 2021 yuzu Emulator Project 1// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version 2// SPDX-License-Identifier: GPL-2.0-or-later
3// Refer to the license.txt file included.
4 3
5#pragma once 4#pragma once
6 5
diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp
index 10b2281db..09398ea64 100644
--- a/src/common/logging/text_formatter.cpp
+++ b/src/common/logging/text_formatter.cpp
@@ -1,6 +1,5 @@
1// Copyright 2014 Citra Emulator Project 1// SPDX-FileCopyrightText: 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version 2// SPDX-License-Identifier: GPL-2.0-or-later
3// Refer to the license.txt file included.
4 3
5#include <array> 4#include <array>
6#include <cstdio> 5#include <cstdio>
@@ -10,12 +9,10 @@
10#endif 9#endif
11 10
12#include "common/assert.h" 11#include "common/assert.h"
13#include "common/common_funcs.h"
14#include "common/logging/filter.h" 12#include "common/logging/filter.h"
15#include "common/logging/log.h" 13#include "common/logging/log.h"
16#include "common/logging/log_entry.h" 14#include "common/logging/log_entry.h"
17#include "common/logging/text_formatter.h" 15#include "common/logging/text_formatter.h"
18#include "common/string_util.h"
19 16
20namespace Common::Log { 17namespace Common::Log {
21 18
diff --git a/src/common/logging/text_formatter.h b/src/common/logging/text_formatter.h
index 171e74cfe..0d0ec4370 100644
--- a/src/common/logging/text_formatter.h
+++ b/src/common/logging/text_formatter.h
@@ -1,10 +1,8 @@
1// Copyright 2014 Citra Emulator Project 1// SPDX-FileCopyrightText: 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version 2// SPDX-License-Identifier: GPL-2.0-or-later
3// Refer to the license.txt file included.
4 3
5#pragma once 4#pragma once
6 5
7#include <cstddef>
8#include <string> 6#include <string>
9 7
10namespace Common::Log { 8namespace Common::Log {
diff --git a/src/common/logging/types.h b/src/common/logging/types.h
index 9ed0c7ad6..595c15ada 100644
--- a/src/common/logging/types.h
+++ b/src/common/logging/types.h
@@ -1,6 +1,5 @@
1// Copyright 2021 yuzu Emulator Project 1// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version 2// SPDX-License-Identifier: GPL-2.0-or-later
3// Refer to the license.txt file included.
4 3
5#pragma once 4#pragma once
6 5
@@ -69,6 +68,7 @@ enum class Class : u8 {
69 Service_GRC, ///< The game recording service 68 Service_GRC, ///< The game recording service
70 Service_HID, ///< The HID (Human interface device) service 69 Service_HID, ///< The HID (Human interface device) service
71 Service_IRS, ///< The IRS service 70 Service_IRS, ///< The IRS service
71 Service_JIT, ///< The JIT service
72 Service_LBL, ///< The LBL (LCD backlight) service 72 Service_LBL, ///< The LBL (LCD backlight) service
73 Service_LDN, ///< The LDN (Local domain network) service 73 Service_LDN, ///< The LDN (Local domain network) service
74 Service_LDR, ///< The loader service 74 Service_LDR, ///< The loader service
@@ -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
@@ -86,6 +87,7 @@ enum class Class : u8 {
86 Service_NPNS, ///< The NPNS service 87 Service_NPNS, ///< The NPNS service
87 Service_NS, ///< The NS services 88 Service_NS, ///< The NS services
88 Service_NVDRV, ///< The NVDRV (Nvidia driver) service 89 Service_NVDRV, ///< The NVDRV (Nvidia driver) service
90 Service_NVFlinger, ///< The NVFlinger service
89 Service_OLSC, ///< The OLSC service 91 Service_OLSC, ///< The OLSC service
90 Service_PCIE, ///< The PCIe service 92 Service_PCIE, ///< The PCIe service
91 Service_PCTL, ///< The PCTL (Parental control) service 93 Service_PCTL, ///< The PCTL (Parental control) service
@@ -93,7 +95,7 @@ enum class Class : u8 {
93 Service_PM, ///< The PM service 95 Service_PM, ///< The PM service
94 Service_PREPO, ///< The PREPO (Play report) service 96 Service_PREPO, ///< The PREPO (Play report) service
95 Service_PSC, ///< The PSC service 97 Service_PSC, ///< The PSC service
96 Service_PSM, ///< The PSM service 98 Service_PTM, ///< The PTM service
97 Service_SET, ///< The SET (Settings) service 99 Service_SET, ///< The SET (Settings) service
98 Service_SM, ///< The SM (Service manager) service 100 Service_SM, ///< The SM (Service manager) service
99 Service_SPL, ///< The SPL service 101 Service_SPL, ///< The SPL service