diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/common/logging/backend.cpp | 129 | ||||
| -rw-r--r-- | src/common/logging/backend.h | 28 | ||||
| -rw-r--r-- | src/common/logging/filter.cpp | 132 | ||||
| -rw-r--r-- | src/common/logging/filter.h | 12 | ||||
| -rw-r--r-- | src/common/logging/log.h | 120 | ||||
| -rw-r--r-- | src/common/logging/text_formatter.cpp | 2 | ||||
| -rw-r--r-- | src/common/logging/types.h | 142 |
8 files changed, 288 insertions, 278 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/logging/backend.cpp b/src/common/logging/backend.cpp index 756b08dfe..d5cff400f 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp | |||
| @@ -198,135 +198,6 @@ void DebuggerBackend::Write(const Entry& entry) { | |||
| 198 | #endif | 198 | #endif |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | /// Macro listing all log classes. Code should define CLS and SUB as desired before invoking this. | ||
| 202 | #define ALL_LOG_CLASSES() \ | ||
| 203 | CLS(Log) \ | ||
| 204 | CLS(Common) \ | ||
| 205 | SUB(Common, Filesystem) \ | ||
| 206 | SUB(Common, Memory) \ | ||
| 207 | CLS(Core) \ | ||
| 208 | SUB(Core, ARM) \ | ||
| 209 | SUB(Core, Timing) \ | ||
| 210 | CLS(Config) \ | ||
| 211 | CLS(Debug) \ | ||
| 212 | SUB(Debug, Emulated) \ | ||
| 213 | SUB(Debug, GPU) \ | ||
| 214 | SUB(Debug, Breakpoint) \ | ||
| 215 | SUB(Debug, GDBStub) \ | ||
| 216 | CLS(Kernel) \ | ||
| 217 | SUB(Kernel, SVC) \ | ||
| 218 | CLS(Service) \ | ||
| 219 | SUB(Service, ACC) \ | ||
| 220 | SUB(Service, Audio) \ | ||
| 221 | SUB(Service, AM) \ | ||
| 222 | SUB(Service, AOC) \ | ||
| 223 | SUB(Service, APM) \ | ||
| 224 | SUB(Service, ARP) \ | ||
| 225 | SUB(Service, BCAT) \ | ||
| 226 | SUB(Service, BPC) \ | ||
| 227 | SUB(Service, BGTC) \ | ||
| 228 | SUB(Service, BTDRV) \ | ||
| 229 | SUB(Service, BTM) \ | ||
| 230 | SUB(Service, Capture) \ | ||
| 231 | SUB(Service, ERPT) \ | ||
| 232 | SUB(Service, ETicket) \ | ||
| 233 | SUB(Service, EUPLD) \ | ||
| 234 | SUB(Service, Fatal) \ | ||
| 235 | SUB(Service, FGM) \ | ||
| 236 | SUB(Service, Friend) \ | ||
| 237 | SUB(Service, FS) \ | ||
| 238 | SUB(Service, GRC) \ | ||
| 239 | SUB(Service, HID) \ | ||
| 240 | SUB(Service, IRS) \ | ||
| 241 | SUB(Service, LBL) \ | ||
| 242 | SUB(Service, LDN) \ | ||
| 243 | SUB(Service, LDR) \ | ||
| 244 | SUB(Service, LM) \ | ||
| 245 | SUB(Service, Migration) \ | ||
| 246 | SUB(Service, Mii) \ | ||
| 247 | SUB(Service, MM) \ | ||
| 248 | SUB(Service, NCM) \ | ||
| 249 | SUB(Service, NFC) \ | ||
| 250 | SUB(Service, NFP) \ | ||
| 251 | SUB(Service, NIFM) \ | ||
| 252 | SUB(Service, NIM) \ | ||
| 253 | SUB(Service, NPNS) \ | ||
| 254 | SUB(Service, NS) \ | ||
| 255 | SUB(Service, NVDRV) \ | ||
| 256 | SUB(Service, OLSC) \ | ||
| 257 | SUB(Service, PCIE) \ | ||
| 258 | SUB(Service, PCTL) \ | ||
| 259 | SUB(Service, PCV) \ | ||
| 260 | SUB(Service, PM) \ | ||
| 261 | SUB(Service, PREPO) \ | ||
| 262 | SUB(Service, PSC) \ | ||
| 263 | SUB(Service, PSM) \ | ||
| 264 | SUB(Service, SET) \ | ||
| 265 | SUB(Service, SM) \ | ||
| 266 | SUB(Service, SPL) \ | ||
| 267 | SUB(Service, SSL) \ | ||
| 268 | SUB(Service, TCAP) \ | ||
| 269 | SUB(Service, Time) \ | ||
| 270 | SUB(Service, USB) \ | ||
| 271 | SUB(Service, VI) \ | ||
| 272 | SUB(Service, WLAN) \ | ||
| 273 | CLS(HW) \ | ||
| 274 | SUB(HW, Memory) \ | ||
| 275 | SUB(HW, LCD) \ | ||
| 276 | SUB(HW, GPU) \ | ||
| 277 | SUB(HW, AES) \ | ||
| 278 | CLS(IPC) \ | ||
| 279 | CLS(Frontend) \ | ||
| 280 | CLS(Render) \ | ||
| 281 | SUB(Render, Software) \ | ||
| 282 | SUB(Render, OpenGL) \ | ||
| 283 | SUB(Render, Vulkan) \ | ||
| 284 | CLS(Audio) \ | ||
| 285 | SUB(Audio, DSP) \ | ||
| 286 | SUB(Audio, Sink) \ | ||
| 287 | CLS(Input) \ | ||
| 288 | CLS(Network) \ | ||
| 289 | CLS(Loader) \ | ||
| 290 | CLS(CheatEngine) \ | ||
| 291 | CLS(Crypto) \ | ||
| 292 | CLS(WebService) | ||
| 293 | |||
| 294 | // GetClassName is a macro defined by Windows.h, grrr... | ||
| 295 | const char* GetLogClassName(Class log_class) { | ||
| 296 | switch (log_class) { | ||
| 297 | #define CLS(x) \ | ||
| 298 | case Class::x: \ | ||
| 299 | return #x; | ||
| 300 | #define SUB(x, y) \ | ||
| 301 | case Class::x##_##y: \ | ||
| 302 | return #x "." #y; | ||
| 303 | ALL_LOG_CLASSES() | ||
| 304 | #undef CLS | ||
| 305 | #undef SUB | ||
| 306 | case Class::Count: | ||
| 307 | break; | ||
| 308 | } | ||
| 309 | return "Invalid"; | ||
| 310 | } | ||
| 311 | |||
| 312 | const char* GetLevelName(Level log_level) { | ||
| 313 | #define LVL(x) \ | ||
| 314 | case Level::x: \ | ||
| 315 | return #x | ||
| 316 | switch (log_level) { | ||
| 317 | LVL(Trace); | ||
| 318 | LVL(Debug); | ||
| 319 | LVL(Info); | ||
| 320 | LVL(Warning); | ||
| 321 | LVL(Error); | ||
| 322 | LVL(Critical); | ||
| 323 | case Level::Count: | ||
| 324 | break; | ||
| 325 | } | ||
| 326 | #undef LVL | ||
| 327 | return "Invalid"; | ||
| 328 | } | ||
| 329 | |||
| 330 | void SetGlobalFilter(const Filter& filter) { | 201 | void SetGlobalFilter(const Filter& filter) { |
| 331 | Impl::Instance().SetGlobalFilter(filter); | 202 | Impl::Instance().SetGlobalFilter(filter); |
| 332 | } | 203 | } |
diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h index 826bde694..4b9a910c1 100644 --- a/src/common/logging/backend.h +++ b/src/common/logging/backend.h | |||
| @@ -1,9 +1,9 @@ | |||
| 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> |
| @@ -20,21 +20,6 @@ namespace Common::Log { | |||
| 20 | class Filter; | 20 | class Filter; |
| 21 | 21 | ||
| 22 | /** | 22 | /** |
| 23 | * A log entry. Log entries are store in a structured format to permit more varied output | ||
| 24 | * formatting on different frontends, as well as facilitating filtering and aggregation. | ||
| 25 | */ | ||
| 26 | struct Entry { | ||
| 27 | std::chrono::microseconds timestamp; | ||
| 28 | Class log_class{}; | ||
| 29 | Level log_level{}; | ||
| 30 | const char* filename = nullptr; | ||
| 31 | unsigned int line_num = 0; | ||
| 32 | std::string function; | ||
| 33 | std::string message; | ||
| 34 | bool final_entry = false; | ||
| 35 | }; | ||
| 36 | |||
| 37 | /** | ||
| 38 | * 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 |
| 39 | * 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 |
| 40 | */ | 25 | */ |
| @@ -131,17 +116,6 @@ void RemoveBackend(std::string_view backend_name); | |||
| 131 | Backend* GetBackend(std::string_view backend_name); | 116 | Backend* GetBackend(std::string_view backend_name); |
| 132 | 117 | ||
| 133 | /** | 118 | /** |
| 134 | * Returns the name of the passed log class as a C-string. Subclasses are separated by periods | ||
| 135 | * instead of underscores as in the enumeration. | ||
| 136 | */ | ||
| 137 | const char* GetLogClassName(Class log_class); | ||
| 138 | |||
| 139 | /** | ||
| 140 | * Returns the name of the passed log level as a C-string. | ||
| 141 | */ | ||
| 142 | const char* GetLevelName(Level log_level); | ||
| 143 | |||
| 144 | /** | ||
| 145 | * 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 |
| 146 | * 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 |
| 147 | * 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 | ||
| 23 | template <typename It> | 22 | template <typename It> |
| 24 | Class GetClassByName(const It begin, const It end) { | 23 | Class 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... | ||
| 158 | const 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 | |||
| 175 | const 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 | |||
| 65 | Filter::Filter(Level default_level) { | 193 | Filter::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 @@ | |||
| 12 | namespace Common::Log { | 13 | namespace 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 | */ | ||
| 19 | const char* GetLogClassName(Class log_class); | ||
| 20 | |||
| 21 | /** | ||
| 22 | * Returns the name of the passed log level as a C-string. | ||
| 23 | */ | ||
| 24 | const 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 | ||
| 10 | namespace Common::Log { | 10 | namespace 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. | ||
| 22 | enum 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 | |||
| 36 | typedef 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 | */ | ||
| 44 | enum 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 |
| 140 | void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename, | 22 | void 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 | |||
| 9 | namespace Common::Log { | ||
| 10 | |||
| 11 | /// Specifies the severity or level of detail of the log message. | ||
| 12 | enum 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 | */ | ||
| 32 | enum 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 | */ | ||
| 131 | struct 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 | ||