summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/CMakeLists.txt1
-rw-r--r--src/common/fs/fs.cpp18
-rw-r--r--src/common/logging/backend.cpp147
-rw-r--r--src/common/logging/backend.h43
-rw-r--r--src/common/logging/filter.cpp132
-rw-r--r--src/common/logging/filter.h12
-rw-r--r--src/common/logging/log.h120
-rw-r--r--src/common/logging/text_formatter.cpp2
-rw-r--r--src/common/logging/types.h142
-rw-r--r--src/core/file_sys/vfs.cpp1
-rw-r--r--src/core/file_sys/vfs_libzip.cpp1
-rw-r--r--src/core/hle/service/bcat/backend/boxcat.cpp1
-rw-r--r--src/core/hle/service/lm/lm.cpp47
-rw-r--r--src/yuzu/configuration/configure_cpu_debug.ui2
14 files changed, 352 insertions, 317 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 97fbdcbf9..7534eb8f1 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -141,6 +141,7 @@ add_library(common STATIC
141 logging/log.h 141 logging/log.h
142 logging/text_formatter.cpp 142 logging/text_formatter.cpp
143 logging/text_formatter.h 143 logging/text_formatter.h
144 logging/types.h
144 lz4_compression.cpp 145 lz4_compression.cpp
145 lz4_compression.h 146 lz4_compression.h
146 math_util.h 147 math_util.h
diff --git a/src/common/fs/fs.cpp b/src/common/fs/fs.cpp
index d492480d9..d3159e908 100644
--- a/src/common/fs/fs.cpp
+++ b/src/common/fs/fs.cpp
@@ -321,7 +321,8 @@ bool RemoveDirContentsRecursively(const fs::path& path) {
321 321
322 std::error_code ec; 322 std::error_code ec;
323 323
324 for (const auto& entry : fs::recursive_directory_iterator(path, ec)) { 324 // TODO (Morph): Replace this with recursive_directory_iterator once it's fixed in MSVC.
325 for (const auto& entry : fs::directory_iterator(path, ec)) {
325 if (ec) { 326 if (ec) {
326 LOG_ERROR(Common_Filesystem, 327 LOG_ERROR(Common_Filesystem,
327 "Failed to completely enumerate the directory at path={}, ec_message={}", 328 "Failed to completely enumerate the directory at path={}, ec_message={}",
@@ -337,6 +338,12 @@ bool RemoveDirContentsRecursively(const fs::path& path) {
337 PathToUTF8String(entry.path()), ec.message()); 338 PathToUTF8String(entry.path()), ec.message());
338 break; 339 break;
339 } 340 }
341
342 // TODO (Morph): Remove this when MSVC fixes recursive_directory_iterator.
343 // recursive_directory_iterator throws an exception despite passing in a std::error_code.
344 if (entry.status().type() == fs::file_type::directory) {
345 return RemoveDirContentsRecursively(entry.path());
346 }
340 } 347 }
341 348
342 if (ec) { 349 if (ec) {
@@ -475,7 +482,8 @@ void IterateDirEntriesRecursively(const std::filesystem::path& path,
475 482
476 std::error_code ec; 483 std::error_code ec;
477 484
478 for (const auto& entry : fs::recursive_directory_iterator(path, ec)) { 485 // TODO (Morph): Replace this with recursive_directory_iterator once it's fixed in MSVC.
486 for (const auto& entry : fs::directory_iterator(path, ec)) {
479 if (ec) { 487 if (ec) {
480 break; 488 break;
481 } 489 }
@@ -495,6 +503,12 @@ void IterateDirEntriesRecursively(const std::filesystem::path& path,
495 break; 503 break;
496 } 504 }
497 } 505 }
506
507 // TODO (Morph): Remove this when MSVC fixes recursive_directory_iterator.
508 // recursive_directory_iterator throws an exception despite passing in a std::error_code.
509 if (entry.status().type() == fs::file_type::directory) {
510 IterateDirEntriesRecursively(entry.path(), callback, filter);
511 }
498 } 512 }
499 513
500 if (callback_error || ec) { 514 if (callback_error || ec) {
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 6aa8ac960..d5cff400f 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -17,6 +17,7 @@
17#endif 17#endif
18 18
19#include "common/assert.h" 19#include "common/assert.h"
20#include "common/fs/file.h"
20#include "common/fs/fs.h" 21#include "common/fs/fs.h"
21#include "common/logging/backend.h" 22#include "common/logging/backend.h"
22#include "common/logging/log.h" 23#include "common/logging/log.h"
@@ -140,10 +141,14 @@ private:
140 std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()}; 141 std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()};
141}; 142};
142 143
144ConsoleBackend::~ConsoleBackend() = default;
145
143void ConsoleBackend::Write(const Entry& entry) { 146void ConsoleBackend::Write(const Entry& entry) {
144 PrintMessage(entry); 147 PrintMessage(entry);
145} 148}
146 149
150ColorConsoleBackend::~ColorConsoleBackend() = default;
151
147void ColorConsoleBackend::Write(const Entry& entry) { 152void ColorConsoleBackend::Write(const Entry& entry) {
148 PrintColoredMessage(entry); 153 PrintColoredMessage(entry);
149} 154}
@@ -157,16 +162,19 @@ FileBackend::FileBackend(const std::filesystem::path& filename) {
157 void(FS::RemoveFile(old_filename)); 162 void(FS::RemoveFile(old_filename));
158 void(FS::RenameFile(filename, old_filename)); 163 void(FS::RenameFile(filename, old_filename));
159 164
160 file = FS::IOFile(filename, FS::FileAccessMode::Write, FS::FileType::TextFile); 165 file =
166 std::make_unique<FS::IOFile>(filename, FS::FileAccessMode::Write, FS::FileType::TextFile);
161} 167}
162 168
169FileBackend::~FileBackend() = default;
170
163void FileBackend::Write(const Entry& entry) { 171void FileBackend::Write(const Entry& entry) {
164 // prevent logs from going over the maximum size (in case its spamming and the user doesn't 172 // prevent logs from going over the maximum size (in case its spamming and the user doesn't
165 // know) 173 // know)
166 constexpr std::size_t MAX_BYTES_WRITTEN = 100 * 1024 * 1024; 174 constexpr std::size_t MAX_BYTES_WRITTEN = 100 * 1024 * 1024;
167 constexpr std::size_t MAX_BYTES_WRITTEN_EXTENDED = 1024 * 1024 * 1024; 175 constexpr std::size_t MAX_BYTES_WRITTEN_EXTENDED = 1024 * 1024 * 1024;
168 176
169 if (!file.IsOpen()) { 177 if (!file->IsOpen()) {
170 return; 178 return;
171 } 179 }
172 180
@@ -176,147 +184,20 @@ void FileBackend::Write(const Entry& entry) {
176 return; 184 return;
177 } 185 }
178 186
179 bytes_written += file.WriteString(FormatLogMessage(entry).append(1, '\n')); 187 bytes_written += file->WriteString(FormatLogMessage(entry).append(1, '\n'));
180 if (entry.log_level >= Level::Error) { 188 if (entry.log_level >= Level::Error) {
181 void(file.Flush()); 189 void(file->Flush());
182 } 190 }
183} 191}
184 192
193DebuggerBackend::~DebuggerBackend() = default;
194
185void DebuggerBackend::Write(const Entry& entry) { 195void DebuggerBackend::Write(const Entry& entry) {
186#ifdef _WIN32 196#ifdef _WIN32
187 ::OutputDebugStringW(UTF8ToUTF16W(FormatLogMessage(entry).append(1, '\n')).c_str()); 197 ::OutputDebugStringW(UTF8ToUTF16W(FormatLogMessage(entry).append(1, '\n')).c_str());
188#endif 198#endif
189} 199}
190 200
191/// Macro listing all log classes. Code should define CLS and SUB as desired before invoking this.
192#define ALL_LOG_CLASSES() \
193 CLS(Log) \
194 CLS(Common) \
195 SUB(Common, Filesystem) \
196 SUB(Common, Memory) \
197 CLS(Core) \
198 SUB(Core, ARM) \
199 SUB(Core, Timing) \
200 CLS(Config) \
201 CLS(Debug) \
202 SUB(Debug, Emulated) \
203 SUB(Debug, GPU) \
204 SUB(Debug, Breakpoint) \
205 SUB(Debug, GDBStub) \
206 CLS(Kernel) \
207 SUB(Kernel, SVC) \
208 CLS(Service) \
209 SUB(Service, ACC) \
210 SUB(Service, Audio) \
211 SUB(Service, AM) \
212 SUB(Service, AOC) \
213 SUB(Service, APM) \
214 SUB(Service, ARP) \
215 SUB(Service, BCAT) \
216 SUB(Service, BPC) \
217 SUB(Service, BGTC) \
218 SUB(Service, BTDRV) \
219 SUB(Service, BTM) \
220 SUB(Service, Capture) \
221 SUB(Service, ERPT) \
222 SUB(Service, ETicket) \
223 SUB(Service, EUPLD) \
224 SUB(Service, Fatal) \
225 SUB(Service, FGM) \
226 SUB(Service, Friend) \
227 SUB(Service, FS) \
228 SUB(Service, GRC) \
229 SUB(Service, HID) \
230 SUB(Service, IRS) \
231 SUB(Service, LBL) \
232 SUB(Service, LDN) \
233 SUB(Service, LDR) \
234 SUB(Service, LM) \
235 SUB(Service, Migration) \
236 SUB(Service, Mii) \
237 SUB(Service, MM) \
238 SUB(Service, NCM) \
239 SUB(Service, NFC) \
240 SUB(Service, NFP) \
241 SUB(Service, NIFM) \
242 SUB(Service, NIM) \
243 SUB(Service, NPNS) \
244 SUB(Service, NS) \
245 SUB(Service, NVDRV) \
246 SUB(Service, OLSC) \
247 SUB(Service, PCIE) \
248 SUB(Service, PCTL) \
249 SUB(Service, PCV) \
250 SUB(Service, PM) \
251 SUB(Service, PREPO) \
252 SUB(Service, PSC) \
253 SUB(Service, PSM) \
254 SUB(Service, SET) \
255 SUB(Service, SM) \
256 SUB(Service, SPL) \
257 SUB(Service, SSL) \
258 SUB(Service, TCAP) \
259 SUB(Service, Time) \
260 SUB(Service, USB) \
261 SUB(Service, VI) \
262 SUB(Service, WLAN) \
263 CLS(HW) \
264 SUB(HW, Memory) \
265 SUB(HW, LCD) \
266 SUB(HW, GPU) \
267 SUB(HW, AES) \
268 CLS(IPC) \
269 CLS(Frontend) \
270 CLS(Render) \
271 SUB(Render, Software) \
272 SUB(Render, OpenGL) \
273 SUB(Render, Vulkan) \
274 CLS(Audio) \
275 SUB(Audio, DSP) \
276 SUB(Audio, Sink) \
277 CLS(Input) \
278 CLS(Network) \
279 CLS(Loader) \
280 CLS(CheatEngine) \
281 CLS(Crypto) \
282 CLS(WebService)
283
284// GetClassName is a macro defined by Windows.h, grrr...
285const char* GetLogClassName(Class log_class) {
286 switch (log_class) {
287#define CLS(x) \
288 case Class::x: \
289 return #x;
290#define SUB(x, y) \
291 case Class::x##_##y: \
292 return #x "." #y;
293 ALL_LOG_CLASSES()
294#undef CLS
295#undef SUB
296 case Class::Count:
297 break;
298 }
299 return "Invalid";
300}
301
302const char* GetLevelName(Level log_level) {
303#define LVL(x) \
304 case Level::x: \
305 return #x
306 switch (log_level) {
307 LVL(Trace);
308 LVL(Debug);
309 LVL(Info);
310 LVL(Warning);
311 LVL(Error);
312 LVL(Critical);
313 case Level::Count:
314 break;
315 }
316#undef LVL
317 return "Invalid";
318}
319
320void SetGlobalFilter(const Filter& filter) { 201void SetGlobalFilter(const Filter& filter) {
321 Impl::Instance().SetGlobalFilter(filter); 202 Impl::Instance().SetGlobalFilter(filter);
322} 203}
diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h
index eb629a33f..4b9a910c1 100644
--- a/src/common/logging/backend.h
+++ b/src/common/logging/backend.h
@@ -1,43 +1,32 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4
4#pragma once 5#pragma once
5 6
6#include <chrono>
7#include <filesystem> 7#include <filesystem>
8#include <memory> 8#include <memory>
9#include <string> 9#include <string>
10#include <string_view> 10#include <string_view>
11#include "common/fs/file.h"
12#include "common/logging/filter.h" 11#include "common/logging/filter.h"
13#include "common/logging/log.h" 12#include "common/logging/log.h"
14 13
14namespace Common::FS {
15class IOFile;
16}
17
15namespace Common::Log { 18namespace Common::Log {
16 19
17class Filter; 20class Filter;
18 21
19/** 22/**
20 * A log entry. Log entries are store in a structured format to permit more varied output
21 * formatting on different frontends, as well as facilitating filtering and aggregation.
22 */
23struct Entry {
24 std::chrono::microseconds timestamp;
25 Class log_class{};
26 Level log_level{};
27 const char* filename = nullptr;
28 unsigned int line_num = 0;
29 std::string function;
30 std::string message;
31 bool final_entry = false;
32};
33
34/**
35 * Interface for logging backends. As loggers can be created and removed at runtime, this can be 23 * Interface for logging backends. As loggers can be created and removed at runtime, this can be
36 * used by a frontend for adding a custom logging backend as needed 24 * used by a frontend for adding a custom logging backend as needed
37 */ 25 */
38class Backend { 26class Backend {
39public: 27public:
40 virtual ~Backend() = default; 28 virtual ~Backend() = default;
29
41 virtual void SetFilter(const Filter& new_filter) { 30 virtual void SetFilter(const Filter& new_filter) {
42 filter = new_filter; 31 filter = new_filter;
43 } 32 }
@@ -53,6 +42,8 @@ private:
53 */ 42 */
54class ConsoleBackend : public Backend { 43class ConsoleBackend : public Backend {
55public: 44public:
45 ~ConsoleBackend() override;
46
56 static const char* Name() { 47 static const char* Name() {
57 return "console"; 48 return "console";
58 } 49 }
@@ -67,6 +58,8 @@ public:
67 */ 58 */
68class ColorConsoleBackend : public Backend { 59class ColorConsoleBackend : public Backend {
69public: 60public:
61 ~ColorConsoleBackend() override;
62
70 static const char* Name() { 63 static const char* Name() {
71 return "color_console"; 64 return "color_console";
72 } 65 }
@@ -83,6 +76,7 @@ public:
83class FileBackend : public Backend { 76class FileBackend : public Backend {
84public: 77public:
85 explicit FileBackend(const std::filesystem::path& filename); 78 explicit FileBackend(const std::filesystem::path& filename);
79 ~FileBackend() override;
86 80
87 static const char* Name() { 81 static const char* Name() {
88 return "file"; 82 return "file";
@@ -95,7 +89,7 @@ public:
95 void Write(const Entry& entry) override; 89 void Write(const Entry& entry) override;
96 90
97private: 91private:
98 FS::IOFile file; 92 std::unique_ptr<FS::IOFile> file;
99 std::size_t bytes_written = 0; 93 std::size_t bytes_written = 0;
100}; 94};
101 95
@@ -104,6 +98,8 @@ private:
104 */ 98 */
105class DebuggerBackend : public Backend { 99class DebuggerBackend : public Backend {
106public: 100public:
101 ~DebuggerBackend() override;
102
107 static const char* Name() { 103 static const char* Name() {
108 return "debugger"; 104 return "debugger";
109 } 105 }
@@ -120,17 +116,6 @@ void RemoveBackend(std::string_view backend_name);
120Backend* GetBackend(std::string_view backend_name); 116Backend* GetBackend(std::string_view backend_name);
121 117
122/** 118/**
123 * Returns the name of the passed log class as a C-string. Subclasses are separated by periods
124 * instead of underscores as in the enumeration.
125 */
126const char* GetLogClassName(Class log_class);
127
128/**
129 * Returns the name of the passed log level as a C-string.
130 */
131const char* GetLevelName(Level log_level);
132
133/**
134 * The global filter will prevent any messages from even being processed if they are filtered. Each 119 * The global filter will prevent any messages from even being processed if they are filtered. Each
135 * backend can have a filter, but if the level is lower than the global filter, the backend will 120 * backend can have a filter, but if the level is lower than the global filter, the backend will
136 * never get the message 121 * never get the message
diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp
index 20a2dd106..4f2cc29e1 100644
--- a/src/common/logging/filter.cpp
+++ b/src/common/logging/filter.cpp
@@ -3,7 +3,6 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm> 5#include <algorithm>
6#include "common/logging/backend.h"
7#include "common/logging/filter.h" 6#include "common/logging/filter.h"
8#include "common/string_util.h" 7#include "common/string_util.h"
9 8
@@ -22,7 +21,7 @@ Level GetLevelByName(const It begin, const It end) {
22 21
23template <typename It> 22template <typename It>
24Class GetClassByName(const It begin, const It end) { 23Class GetClassByName(const It begin, const It end) {
25 for (ClassType i = 0; i < static_cast<ClassType>(Class::Count); ++i) { 24 for (u8 i = 0; i < static_cast<u8>(Class::Count); ++i) {
26 const char* level_name = GetLogClassName(static_cast<Class>(i)); 25 const char* level_name = GetLogClassName(static_cast<Class>(i));
27 if (Common::ComparePartialString(begin, end, level_name)) { 26 if (Common::ComparePartialString(begin, end, level_name)) {
28 return static_cast<Class>(i); 27 return static_cast<Class>(i);
@@ -62,6 +61,135 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
62} 61}
63} // Anonymous namespace 62} // Anonymous namespace
64 63
64/// Macro listing all log classes. Code should define CLS and SUB as desired before invoking this.
65#define ALL_LOG_CLASSES() \
66 CLS(Log) \
67 CLS(Common) \
68 SUB(Common, Filesystem) \
69 SUB(Common, Memory) \
70 CLS(Core) \
71 SUB(Core, ARM) \
72 SUB(Core, Timing) \
73 CLS(Config) \
74 CLS(Debug) \
75 SUB(Debug, Emulated) \
76 SUB(Debug, GPU) \
77 SUB(Debug, Breakpoint) \
78 SUB(Debug, GDBStub) \
79 CLS(Kernel) \
80 SUB(Kernel, SVC) \
81 CLS(Service) \
82 SUB(Service, ACC) \
83 SUB(Service, Audio) \
84 SUB(Service, AM) \
85 SUB(Service, AOC) \
86 SUB(Service, APM) \
87 SUB(Service, ARP) \
88 SUB(Service, BCAT) \
89 SUB(Service, BPC) \
90 SUB(Service, BGTC) \
91 SUB(Service, BTDRV) \
92 SUB(Service, BTM) \
93 SUB(Service, Capture) \
94 SUB(Service, ERPT) \
95 SUB(Service, ETicket) \
96 SUB(Service, EUPLD) \
97 SUB(Service, Fatal) \
98 SUB(Service, FGM) \
99 SUB(Service, Friend) \
100 SUB(Service, FS) \
101 SUB(Service, GRC) \
102 SUB(Service, HID) \
103 SUB(Service, IRS) \
104 SUB(Service, LBL) \
105 SUB(Service, LDN) \
106 SUB(Service, LDR) \
107 SUB(Service, LM) \
108 SUB(Service, Migration) \
109 SUB(Service, Mii) \
110 SUB(Service, MM) \
111 SUB(Service, NCM) \
112 SUB(Service, NFC) \
113 SUB(Service, NFP) \
114 SUB(Service, NIFM) \
115 SUB(Service, NIM) \
116 SUB(Service, NPNS) \
117 SUB(Service, NS) \
118 SUB(Service, NVDRV) \
119 SUB(Service, OLSC) \
120 SUB(Service, PCIE) \
121 SUB(Service, PCTL) \
122 SUB(Service, PCV) \
123 SUB(Service, PM) \
124 SUB(Service, PREPO) \
125 SUB(Service, PSC) \
126 SUB(Service, PSM) \
127 SUB(Service, SET) \
128 SUB(Service, SM) \
129 SUB(Service, SPL) \
130 SUB(Service, SSL) \
131 SUB(Service, TCAP) \
132 SUB(Service, Time) \
133 SUB(Service, USB) \
134 SUB(Service, VI) \
135 SUB(Service, WLAN) \
136 CLS(HW) \
137 SUB(HW, Memory) \
138 SUB(HW, LCD) \
139 SUB(HW, GPU) \
140 SUB(HW, AES) \
141 CLS(IPC) \
142 CLS(Frontend) \
143 CLS(Render) \
144 SUB(Render, Software) \
145 SUB(Render, OpenGL) \
146 SUB(Render, Vulkan) \
147 CLS(Audio) \
148 SUB(Audio, DSP) \
149 SUB(Audio, Sink) \
150 CLS(Input) \
151 CLS(Network) \
152 CLS(Loader) \
153 CLS(CheatEngine) \
154 CLS(Crypto) \
155 CLS(WebService)
156
157// GetClassName is a macro defined by Windows.h, grrr...
158const char* GetLogClassName(Class log_class) {
159 switch (log_class) {
160#define CLS(x) \
161 case Class::x: \
162 return #x;
163#define SUB(x, y) \
164 case Class::x##_##y: \
165 return #x "." #y;
166 ALL_LOG_CLASSES()
167#undef CLS
168#undef SUB
169 case Class::Count:
170 break;
171 }
172 return "Invalid";
173}
174
175const char* GetLevelName(Level log_level) {
176#define LVL(x) \
177 case Level::x: \
178 return #x
179 switch (log_level) {
180 LVL(Trace);
181 LVL(Debug);
182 LVL(Info);
183 LVL(Warning);
184 LVL(Error);
185 LVL(Critical);
186 case Level::Count:
187 break;
188 }
189#undef LVL
190 return "Invalid";
191}
192
65Filter::Filter(Level default_level) { 193Filter::Filter(Level default_level) {
66 ResetAll(default_level); 194 ResetAll(default_level);
67} 195}
diff --git a/src/common/logging/filter.h b/src/common/logging/filter.h
index f5673a9f6..1a3074e04 100644
--- a/src/common/logging/filter.h
+++ b/src/common/logging/filter.h
@@ -5,6 +5,7 @@
5#pragma once 5#pragma once
6 6
7#include <array> 7#include <array>
8#include <chrono>
8#include <cstddef> 9#include <cstddef>
9#include <string_view> 10#include <string_view>
10#include "common/logging/log.h" 11#include "common/logging/log.h"
@@ -12,6 +13,17 @@
12namespace Common::Log { 13namespace Common::Log {
13 14
14/** 15/**
16 * Returns the name of the passed log class as a C-string. Subclasses are separated by periods
17 * instead of underscores as in the enumeration.
18 */
19const char* GetLogClassName(Class log_class);
20
21/**
22 * Returns the name of the passed log level as a C-string.
23 */
24const char* GetLevelName(Level log_level);
25
26/**
15 * Implements a log message filter which allows different log classes to have different minimum 27 * Implements a log message filter which allows different log classes to have different minimum
16 * severity levels. The filter can be changed at runtime and can be parsed from a string to allow 28 * severity levels. The filter can be changed at runtime and can be parsed from a string to allow
17 * editing via the interface or loading from a configuration file. 29 * editing via the interface or loading from a configuration file.
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 1f0f8db52..8d43eddc7 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -5,7 +5,7 @@
5#pragma once 5#pragma once
6 6
7#include <fmt/format.h> 7#include <fmt/format.h>
8#include "common/common_types.h" 8#include "common/logging/types.h"
9 9
10namespace Common::Log { 10namespace Common::Log {
11 11
@@ -18,124 +18,6 @@ constexpr const char* TrimSourcePath(std::string_view source) {
18 return source.data() + idx; 18 return source.data() + idx;
19} 19}
20 20
21/// Specifies the severity or level of detail of the log message.
22enum class Level : u8 {
23 Trace, ///< Extremely detailed and repetitive debugging information that is likely to
24 ///< pollute logs.
25 Debug, ///< Less detailed debugging information.
26 Info, ///< Status information from important points during execution.
27 Warning, ///< Minor or potential problems found during execution of a task.
28 Error, ///< Major problems found during execution of a task that prevent it from being
29 ///< completed.
30 Critical, ///< Major problems during execution that threaten the stability of the entire
31 ///< application.
32
33 Count ///< Total number of logging levels
34};
35
36typedef u8 ClassType;
37
38/**
39 * Specifies the sub-system that generated the log message.
40 *
41 * @note If you add a new entry here, also add a corresponding one to `ALL_LOG_CLASSES` in
42 * backend.cpp.
43 */
44enum class Class : ClassType {
45 Log, ///< Messages about the log system itself
46 Common, ///< Library routines
47 Common_Filesystem, ///< Filesystem interface library
48 Common_Memory, ///< Memory mapping and management functions
49 Core, ///< LLE emulation core
50 Core_ARM, ///< ARM CPU core
51 Core_Timing, ///< CoreTiming functions
52 Config, ///< Emulator configuration (including commandline)
53 Debug, ///< Debugging tools
54 Debug_Emulated, ///< Debug messages from the emulated programs
55 Debug_GPU, ///< GPU debugging tools
56 Debug_Breakpoint, ///< Logging breakpoints and watchpoints
57 Debug_GDBStub, ///< GDB Stub
58 Kernel, ///< The HLE implementation of the CTR kernel
59 Kernel_SVC, ///< Kernel system calls
60 Service, ///< HLE implementation of system services. Each major service
61 ///< should have its own subclass.
62 Service_ACC, ///< The ACC (Accounts) service
63 Service_AM, ///< The AM (Applet manager) service
64 Service_AOC, ///< The AOC (AddOn Content) service
65 Service_APM, ///< The APM (Performance) service
66 Service_ARP, ///< The ARP service
67 Service_Audio, ///< The Audio (Audio control) service
68 Service_BCAT, ///< The BCAT service
69 Service_BGTC, ///< The BGTC (Background Task Controller) service
70 Service_BPC, ///< The BPC service
71 Service_BTDRV, ///< The Bluetooth driver service
72 Service_BTM, ///< The BTM service
73 Service_Capture, ///< The capture service
74 Service_ERPT, ///< The error reporting service
75 Service_ETicket, ///< The ETicket service
76 Service_EUPLD, ///< The error upload service
77 Service_Fatal, ///< The Fatal service
78 Service_FGM, ///< The FGM service
79 Service_Friend, ///< The friend service
80 Service_FS, ///< The FS (Filesystem) service
81 Service_GRC, ///< The game recording service
82 Service_HID, ///< The HID (Human interface device) service
83 Service_IRS, ///< The IRS service
84 Service_LBL, ///< The LBL (LCD backlight) service
85 Service_LDN, ///< The LDN (Local domain network) service
86 Service_LDR, ///< The loader service
87 Service_LM, ///< The LM (Logger) service
88 Service_Migration, ///< The migration service
89 Service_Mii, ///< The Mii service
90 Service_MM, ///< The MM (Multimedia) service
91 Service_NCM, ///< The NCM service
92 Service_NFC, ///< The NFC (Near-field communication) service
93 Service_NFP, ///< The NFP service
94 Service_NIFM, ///< The NIFM (Network interface) service
95 Service_NIM, ///< The NIM service
96 Service_NPNS, ///< The NPNS service
97 Service_NS, ///< The NS services
98 Service_NVDRV, ///< The NVDRV (Nvidia driver) service
99 Service_OLSC, ///< The OLSC service
100 Service_PCIE, ///< The PCIe service
101 Service_PCTL, ///< The PCTL (Parental control) service
102 Service_PCV, ///< The PCV service
103 Service_PM, ///< The PM service
104 Service_PREPO, ///< The PREPO (Play report) service
105 Service_PSC, ///< The PSC service
106 Service_PSM, ///< The PSM service
107 Service_SET, ///< The SET (Settings) service
108 Service_SM, ///< The SM (Service manager) service
109 Service_SPL, ///< The SPL service
110 Service_SSL, ///< The SSL service
111 Service_TCAP, ///< The TCAP service.
112 Service_Time, ///< The time service
113 Service_USB, ///< The USB (Universal Serial Bus) service
114 Service_VI, ///< The VI (Video interface) service
115 Service_WLAN, ///< The WLAN (Wireless local area network) service
116 HW, ///< Low-level hardware emulation
117 HW_Memory, ///< Memory-map and address translation
118 HW_LCD, ///< LCD register emulation
119 HW_GPU, ///< GPU control emulation
120 HW_AES, ///< AES engine emulation
121 IPC, ///< IPC interface
122 Frontend, ///< Emulator UI
123 Render, ///< Emulator video output and hardware acceleration
124 Render_Software, ///< Software renderer backend
125 Render_OpenGL, ///< OpenGL backend
126 Render_Vulkan, ///< Vulkan backend
127 Audio, ///< Audio emulation
128 Audio_DSP, ///< The HLE implementation of the DSP
129 Audio_Sink, ///< Emulator audio output backend
130 Loader, ///< ROM loader
131 CheatEngine, ///< Memory manipulation and engine VM functions
132 Crypto, ///< Cryptographic engine/functions
133 Input, ///< Input emulation
134 Network, ///< Network emulation
135 WebService, ///< Interface to yuzu Web Services
136 Count ///< Total number of logging classes
137};
138
139/// Logs a message to the global logger, using fmt 21/// Logs a message to the global logger, using fmt
140void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename, 22void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
141 unsigned int line_num, const char* function, const char* format, 23 unsigned int line_num, const char* function, const char* format,
diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp
index 80ee2cca1..cfc0d5846 100644
--- a/src/common/logging/text_formatter.cpp
+++ b/src/common/logging/text_formatter.cpp
@@ -11,7 +11,7 @@
11 11
12#include "common/assert.h" 12#include "common/assert.h"
13#include "common/common_funcs.h" 13#include "common/common_funcs.h"
14#include "common/logging/backend.h" 14#include "common/logging/filter.h"
15#include "common/logging/log.h" 15#include "common/logging/log.h"
16#include "common/logging/text_formatter.h" 16#include "common/logging/text_formatter.h"
17#include "common/string_util.h" 17#include "common/string_util.h"
diff --git a/src/common/logging/types.h b/src/common/logging/types.h
new file mode 100644
index 000000000..ee9a1ed84
--- /dev/null
+++ b/src/common/logging/types.h
@@ -0,0 +1,142 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <chrono>
6
7#include "common/common_types.h"
8
9namespace Common::Log {
10
11/// Specifies the severity or level of detail of the log message.
12enum class Level : u8 {
13 Trace, ///< Extremely detailed and repetitive debugging information that is likely to
14 ///< pollute logs.
15 Debug, ///< Less detailed debugging information.
16 Info, ///< Status information from important points during execution.
17 Warning, ///< Minor or potential problems found during execution of a task.
18 Error, ///< Major problems found during execution of a task that prevent it from being
19 ///< completed.
20 Critical, ///< Major problems during execution that threaten the stability of the entire
21 ///< application.
22
23 Count ///< Total number of logging levels
24};
25
26/**
27 * Specifies the sub-system that generated the log message.
28 *
29 * @note If you add a new entry here, also add a corresponding one to `ALL_LOG_CLASSES` in
30 * filter.cpp.
31 */
32enum class Class : u8 {
33 Log, ///< Messages about the log system itself
34 Common, ///< Library routines
35 Common_Filesystem, ///< Filesystem interface library
36 Common_Memory, ///< Memory mapping and management functions
37 Core, ///< LLE emulation core
38 Core_ARM, ///< ARM CPU core
39 Core_Timing, ///< CoreTiming functions
40 Config, ///< Emulator configuration (including commandline)
41 Debug, ///< Debugging tools
42 Debug_Emulated, ///< Debug messages from the emulated programs
43 Debug_GPU, ///< GPU debugging tools
44 Debug_Breakpoint, ///< Logging breakpoints and watchpoints
45 Debug_GDBStub, ///< GDB Stub
46 Kernel, ///< The HLE implementation of the CTR kernel
47 Kernel_SVC, ///< Kernel system calls
48 Service, ///< HLE implementation of system services. Each major service
49 ///< should have its own subclass.
50 Service_ACC, ///< The ACC (Accounts) service
51 Service_AM, ///< The AM (Applet manager) service
52 Service_AOC, ///< The AOC (AddOn Content) service
53 Service_APM, ///< The APM (Performance) service
54 Service_ARP, ///< The ARP service
55 Service_Audio, ///< The Audio (Audio control) service
56 Service_BCAT, ///< The BCAT service
57 Service_BGTC, ///< The BGTC (Background Task Controller) service
58 Service_BPC, ///< The BPC service
59 Service_BTDRV, ///< The Bluetooth driver service
60 Service_BTM, ///< The BTM service
61 Service_Capture, ///< The capture service
62 Service_ERPT, ///< The error reporting service
63 Service_ETicket, ///< The ETicket service
64 Service_EUPLD, ///< The error upload service
65 Service_Fatal, ///< The Fatal service
66 Service_FGM, ///< The FGM service
67 Service_Friend, ///< The friend service
68 Service_FS, ///< The FS (Filesystem) service
69 Service_GRC, ///< The game recording service
70 Service_HID, ///< The HID (Human interface device) service
71 Service_IRS, ///< The IRS service
72 Service_LBL, ///< The LBL (LCD backlight) service
73 Service_LDN, ///< The LDN (Local domain network) service
74 Service_LDR, ///< The loader service
75 Service_LM, ///< The LM (Logger) service
76 Service_Migration, ///< The migration service
77 Service_Mii, ///< The Mii service
78 Service_MM, ///< The MM (Multimedia) service
79 Service_NCM, ///< The NCM service
80 Service_NFC, ///< The NFC (Near-field communication) service
81 Service_NFP, ///< The NFP service
82 Service_NIFM, ///< The NIFM (Network interface) service
83 Service_NIM, ///< The NIM service
84 Service_NPNS, ///< The NPNS service
85 Service_NS, ///< The NS services
86 Service_NVDRV, ///< The NVDRV (Nvidia driver) service
87 Service_OLSC, ///< The OLSC service
88 Service_PCIE, ///< The PCIe service
89 Service_PCTL, ///< The PCTL (Parental control) service
90 Service_PCV, ///< The PCV service
91 Service_PM, ///< The PM service
92 Service_PREPO, ///< The PREPO (Play report) service
93 Service_PSC, ///< The PSC service
94 Service_PSM, ///< The PSM service
95 Service_SET, ///< The SET (Settings) service
96 Service_SM, ///< The SM (Service manager) service
97 Service_SPL, ///< The SPL service
98 Service_SSL, ///< The SSL service
99 Service_TCAP, ///< The TCAP service.
100 Service_Time, ///< The time service
101 Service_USB, ///< The USB (Universal Serial Bus) service
102 Service_VI, ///< The VI (Video interface) service
103 Service_WLAN, ///< The WLAN (Wireless local area network) service
104 HW, ///< Low-level hardware emulation
105 HW_Memory, ///< Memory-map and address translation
106 HW_LCD, ///< LCD register emulation
107 HW_GPU, ///< GPU control emulation
108 HW_AES, ///< AES engine emulation
109 IPC, ///< IPC interface
110 Frontend, ///< Emulator UI
111 Render, ///< Emulator video output and hardware acceleration
112 Render_Software, ///< Software renderer backend
113 Render_OpenGL, ///< OpenGL backend
114 Render_Vulkan, ///< Vulkan backend
115 Audio, ///< Audio emulation
116 Audio_DSP, ///< The HLE implementation of the DSP
117 Audio_Sink, ///< Emulator audio output backend
118 Loader, ///< ROM loader
119 CheatEngine, ///< Memory manipulation and engine VM functions
120 Crypto, ///< Cryptographic engine/functions
121 Input, ///< Input emulation
122 Network, ///< Network emulation
123 WebService, ///< Interface to yuzu Web Services
124 Count ///< Total number of logging classes
125};
126
127/**
128 * A log entry. Log entries are store in a structured format to permit more varied output
129 * formatting on different frontends, as well as facilitating filtering and aggregation.
130 */
131struct Entry {
132 std::chrono::microseconds timestamp;
133 Class log_class{};
134 Level log_level{};
135 const char* filename = nullptr;
136 unsigned int line_num = 0;
137 std::string function;
138 std::string message;
139 bool final_entry = false;
140};
141
142} // namespace Common::Log
diff --git a/src/core/file_sys/vfs.cpp b/src/core/file_sys/vfs.cpp
index 215e1cb1a..368419eca 100644
--- a/src/core/file_sys/vfs.cpp
+++ b/src/core/file_sys/vfs.cpp
@@ -6,7 +6,6 @@
6#include <numeric> 6#include <numeric>
7#include <string> 7#include <string>
8#include "common/fs/path_util.h" 8#include "common/fs/path_util.h"
9#include "common/logging/backend.h"
10#include "core/file_sys/mode.h" 9#include "core/file_sys/mode.h"
11#include "core/file_sys/vfs.h" 10#include "core/file_sys/vfs.h"
12 11
diff --git a/src/core/file_sys/vfs_libzip.cpp b/src/core/file_sys/vfs_libzip.cpp
index cd162c0c3..00e256779 100644
--- a/src/core/file_sys/vfs_libzip.cpp
+++ b/src/core/file_sys/vfs_libzip.cpp
@@ -14,7 +14,6 @@
14#endif 14#endif
15 15
16#include "common/fs/path_util.h" 16#include "common/fs/path_util.h"
17#include "common/logging/backend.h"
18#include "core/file_sys/vfs.h" 17#include "core/file_sys/vfs.h"
19#include "core/file_sys/vfs_libzip.h" 18#include "core/file_sys/vfs_libzip.h"
20#include "core/file_sys/vfs_vector.h" 19#include "core/file_sys/vfs_vector.h"
diff --git a/src/core/hle/service/bcat/backend/boxcat.cpp b/src/core/hle/service/bcat/backend/boxcat.cpp
index d9fdc2dca..a2844ea8c 100644
--- a/src/core/hle/service/bcat/backend/boxcat.cpp
+++ b/src/core/hle/service/bcat/backend/boxcat.cpp
@@ -19,7 +19,6 @@
19#include "common/fs/fs.h" 19#include "common/fs/fs.h"
20#include "common/fs/path_util.h" 20#include "common/fs/path_util.h"
21#include "common/hex_util.h" 21#include "common/hex_util.h"
22#include "common/logging/backend.h"
23#include "common/logging/log.h" 22#include "common/logging/log.h"
24#include "common/settings.h" 23#include "common/settings.h"
25#include "core/core.h" 24#include "core/core.h"
diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp
index 311e4fb2d..794504314 100644
--- a/src/core/hle/service/lm/lm.cpp
+++ b/src/core/hle/service/lm/lm.cpp
@@ -51,6 +51,24 @@ struct hash<Service::LM::LogPacketHeaderEntry> {
51} // namespace std 51} // namespace std
52 52
53namespace Service::LM { 53namespace Service::LM {
54namespace {
55std::string_view NameOf(LogSeverity severity) {
56 switch (severity) {
57 case LogSeverity::Trace:
58 return "TRACE";
59 case LogSeverity::Info:
60 return "INFO";
61 case LogSeverity::Warning:
62 return "WARNING";
63 case LogSeverity::Error:
64 return "ERROR";
65 case LogSeverity::Fatal:
66 return "FATAL";
67 default:
68 return "UNKNOWN";
69 }
70}
71} // Anonymous namespace
54 72
55enum class LogDestination : u32 { 73enum class LogDestination : u32 {
56 TargetManager = 1 << 0, 74 TargetManager = 1 << 0,
@@ -262,33 +280,8 @@ private:
262 if (text_log) { 280 if (text_log) {
263 output_log += fmt::format("Log Text: {}\n", *text_log); 281 output_log += fmt::format("Log Text: {}\n", *text_log);
264 } 282 }
265 283 LOG_DEBUG(Service_LM, "LogManager {} ({}):\n{}", NameOf(entry.severity),
266 switch (entry.severity) { 284 DestinationToString(destination), output_log);
267 case LogSeverity::Trace:
268 LOG_DEBUG(Service_LM, "LogManager TRACE ({}):\n{}", DestinationToString(destination),
269 output_log);
270 break;
271 case LogSeverity::Info:
272 LOG_INFO(Service_LM, "LogManager INFO ({}):\n{}", DestinationToString(destination),
273 output_log);
274 break;
275 case LogSeverity::Warning:
276 LOG_WARNING(Service_LM, "LogManager WARNING ({}):\n{}",
277 DestinationToString(destination), output_log);
278 break;
279 case LogSeverity::Error:
280 LOG_ERROR(Service_LM, "LogManager ERROR ({}):\n{}", DestinationToString(destination),
281 output_log);
282 break;
283 case LogSeverity::Fatal:
284 LOG_CRITICAL(Service_LM, "LogManager FATAL ({}):\n{}", DestinationToString(destination),
285 output_log);
286 break;
287 default:
288 LOG_CRITICAL(Service_LM, "LogManager UNKNOWN ({}):\n{}",
289 DestinationToString(destination), output_log);
290 break;
291 }
292 } 285 }
293 286
294 static std::string DestinationToString(LogDestination destination) { 287 static std::string DestinationToString(LogDestination destination) {
diff --git a/src/yuzu/configuration/configure_cpu_debug.ui b/src/yuzu/configuration/configure_cpu_debug.ui
index 11ee19a12..c43f89a5a 100644
--- a/src/yuzu/configuration/configure_cpu_debug.ui
+++ b/src/yuzu/configuration/configure_cpu_debug.ui
@@ -34,7 +34,7 @@
34 &lt;br&gt; 34 &lt;br&gt;
35 If you're not sure what these do, keep all of these enabled. 35 If you're not sure what these do, keep all of these enabled.
36 &lt;br&gt; 36 &lt;br&gt;
37 These settings only take effect when CPU Accuracy is "Debug Mode". 37 These settings, when disabled, only take effect when CPU Accuracy is "Debug Mode".
38 &lt;/div&gt; 38 &lt;/div&gt;
39 </string> 39 </string>
40 </property> 40 </property>