summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2021-04-14 20:19:52 -0400
committerGravatar Lioncash2021-04-14 23:10:58 -0400
commit64606aefcf2407513d3687a1f8d325653bde1f72 (patch)
treee6d171bdaf94d121809cf8f27a00f417bda39f06 /src
parentMerge pull request #6192 from lioncash/discard (diff)
downloadyuzu-64606aefcf2407513d3687a1f8d325653bde1f72.tar.gz
yuzu-64606aefcf2407513d3687a1f8d325653bde1f72.tar.xz
yuzu-64606aefcf2407513d3687a1f8d325653bde1f72.zip
common/log: Move Log namespace into the Common namespace
Forgot to move this over when I moved the rest of the source files with lacking namespaces over.
Diffstat (limited to 'src')
-rw-r--r--src/common/logging/backend.cpp18
-rw-r--r--src/common/logging/backend.h4
-rw-r--r--src/common/logging/filter.cpp4
-rw-r--r--src/common/logging/filter.h4
-rw-r--r--src/common/logging/log.h34
-rw-r--r--src/common/logging/text_formatter.cpp4
-rw-r--r--src/common/logging/text_formatter.h4
-rw-r--r--src/yuzu/configuration/configure_debug.cpp4
-rw-r--r--src/yuzu/debugger/console.cpp8
-rw-r--r--src/yuzu/main.cpp6
-rw-r--r--src/yuzu_cmd/yuzu.cpp6
11 files changed, 53 insertions, 43 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 4575df24d..c06364977 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -25,7 +25,7 @@
25#include "common/threadsafe_queue.h" 25#include "common/threadsafe_queue.h"
26#include "core/settings.h" 26#include "core/settings.h"
27 27
28namespace Log { 28namespace Common::Log {
29 29
30/** 30/**
31 * Static state as a singleton. 31 * Static state as a singleton.
@@ -132,7 +132,7 @@ private:
132 std::mutex writing_mutex; 132 std::mutex writing_mutex;
133 std::thread backend_thread; 133 std::thread backend_thread;
134 std::vector<std::unique_ptr<Backend>> backends; 134 std::vector<std::unique_ptr<Backend>> backends;
135 Common::MPSCQueue<Log::Entry> message_queue; 135 MPSCQueue<Entry> message_queue;
136 Filter filter; 136 Filter filter;
137 std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()}; 137 std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()};
138}; 138};
@@ -146,16 +146,16 @@ void ColorConsoleBackend::Write(const Entry& entry) {
146} 146}
147 147
148FileBackend::FileBackend(const std::string& filename) : bytes_written(0) { 148FileBackend::FileBackend(const std::string& filename) : bytes_written(0) {
149 if (Common::FS::Exists(filename + ".old.txt")) { 149 if (FS::Exists(filename + ".old.txt")) {
150 Common::FS::Delete(filename + ".old.txt"); 150 FS::Delete(filename + ".old.txt");
151 } 151 }
152 if (Common::FS::Exists(filename)) { 152 if (FS::Exists(filename)) {
153 Common::FS::Rename(filename, filename + ".old.txt"); 153 FS::Rename(filename, filename + ".old.txt");
154 } 154 }
155 155
156 // _SH_DENYWR allows read only access to the file for other programs. 156 // _SH_DENYWR allows read only access to the file for other programs.
157 // It is #defined to 0 on other platforms 157 // It is #defined to 0 on other platforms
158 file = Common::FS::IOFile(filename, "w", _SH_DENYWR); 158 file = FS::IOFile(filename, "w", _SH_DENYWR);
159} 159}
160 160
161void FileBackend::Write(const Entry& entry) { 161void FileBackend::Write(const Entry& entry) {
@@ -182,7 +182,7 @@ void FileBackend::Write(const Entry& entry) {
182 182
183void DebuggerBackend::Write(const Entry& entry) { 183void DebuggerBackend::Write(const Entry& entry) {
184#ifdef _WIN32 184#ifdef _WIN32
185 ::OutputDebugStringW(Common::UTF8ToUTF16W(FormatLogMessage(entry).append(1, '\n')).c_str()); 185 ::OutputDebugStringW(UTF8ToUTF16W(FormatLogMessage(entry).append(1, '\n')).c_str());
186#endif 186#endif
187} 187}
188 188
@@ -342,4 +342,4 @@ void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
342 instance.PushEntry(log_class, log_level, filename, line_num, function, 342 instance.PushEntry(log_class, log_level, filename, line_num, function,
343 fmt::vformat(format, args)); 343 fmt::vformat(format, args));
344} 344}
345} // namespace Log 345} // namespace Common::Log
diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h
index da1c2f185..84a544ea4 100644
--- a/src/common/logging/backend.h
+++ b/src/common/logging/backend.h
@@ -11,7 +11,7 @@
11#include "common/logging/filter.h" 11#include "common/logging/filter.h"
12#include "common/logging/log.h" 12#include "common/logging/log.h"
13 13
14namespace Log { 14namespace Common::Log {
15 15
16class Filter; 16class Filter;
17 17
@@ -135,4 +135,4 @@ const char* GetLevelName(Level log_level);
135 * never get the message 135 * never get the message
136 */ 136 */
137void SetGlobalFilter(const Filter& filter); 137void SetGlobalFilter(const Filter& filter);
138} // namespace Log \ No newline at end of file 138} // namespace Common::Log \ No newline at end of file
diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp
index 2eccbcd8d..20a2dd106 100644
--- a/src/common/logging/filter.cpp
+++ b/src/common/logging/filter.cpp
@@ -7,7 +7,7 @@
7#include "common/logging/filter.h" 7#include "common/logging/filter.h"
8#include "common/string_util.h" 8#include "common/string_util.h"
9 9
10namespace Log { 10namespace Common::Log {
11namespace { 11namespace {
12template <typename It> 12template <typename It>
13Level GetLevelByName(const It begin, const It end) { 13Level GetLevelByName(const It begin, const It end) {
@@ -103,4 +103,4 @@ bool Filter::IsDebug() const {
103 }); 103 });
104} 104}
105 105
106} // namespace Log 106} // namespace Common::Log
diff --git a/src/common/logging/filter.h b/src/common/logging/filter.h
index 773df6f2c..f5673a9f6 100644
--- a/src/common/logging/filter.h
+++ b/src/common/logging/filter.h
@@ -9,7 +9,7 @@
9#include <string_view> 9#include <string_view>
10#include "common/logging/log.h" 10#include "common/logging/log.h"
11 11
12namespace Log { 12namespace Common::Log {
13 13
14/** 14/**
15 * Implements a log message filter which allows different log classes to have different minimum 15 * Implements a log message filter which allows different log classes to have different minimum
@@ -51,4 +51,4 @@ public:
51private: 51private:
52 std::array<Level, static_cast<std::size_t>(Class::Count)> class_levels; 52 std::array<Level, static_cast<std::size_t>(Class::Count)> class_levels;
53}; 53};
54} // namespace Log 54} // namespace Common::Log
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 3d7b7dab7..1f0f8db52 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -7,7 +7,7 @@
7#include <fmt/format.h> 7#include <fmt/format.h>
8#include "common/common_types.h" 8#include "common/common_types.h"
9 9
10namespace Log { 10namespace Common::Log {
11 11
12// trims up to and including the last of ../, ..\, src/, src\ in a string 12// trims up to and including the last of ../, ..\, src/, src\ in a string
13constexpr const char* TrimSourcePath(std::string_view source) { 13constexpr const char* TrimSourcePath(std::string_view source) {
@@ -148,28 +148,34 @@ void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsig
148 fmt::make_format_args(args...)); 148 fmt::make_format_args(args...));
149} 149}
150 150
151} // namespace Log 151} // namespace Common::Log
152 152
153#ifdef _DEBUG 153#ifdef _DEBUG
154#define LOG_TRACE(log_class, ...) \ 154#define LOG_TRACE(log_class, ...) \
155 ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Trace, \ 155 Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Trace, \
156 ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__) 156 Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \
157 __VA_ARGS__)
157#else 158#else
158#define LOG_TRACE(log_class, fmt, ...) (void(0)) 159#define LOG_TRACE(log_class, fmt, ...) (void(0))
159#endif 160#endif
160 161
161#define LOG_DEBUG(log_class, ...) \ 162#define LOG_DEBUG(log_class, ...) \
162 ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Debug, \ 163 Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Debug, \
163 ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__) 164 Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \
165 __VA_ARGS__)
164#define LOG_INFO(log_class, ...) \ 166#define LOG_INFO(log_class, ...) \
165 ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Info, \ 167 Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Info, \
166 ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__) 168 Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \
169 __VA_ARGS__)
167#define LOG_WARNING(log_class, ...) \ 170#define LOG_WARNING(log_class, ...) \
168 ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Warning, \ 171 Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Warning, \
169 ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__) 172 Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \
173 __VA_ARGS__)
170#define LOG_ERROR(log_class, ...) \ 174#define LOG_ERROR(log_class, ...) \
171 ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Error, \ 175 Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Error, \
172 ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__) 176 Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \
177 __VA_ARGS__)
173#define LOG_CRITICAL(log_class, ...) \ 178#define LOG_CRITICAL(log_class, ...) \
174 ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Critical, \ 179 Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Critical, \
175 ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__) 180 Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \
181 __VA_ARGS__)
diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp
index 6a0605c63..80ee2cca1 100644
--- a/src/common/logging/text_formatter.cpp
+++ b/src/common/logging/text_formatter.cpp
@@ -16,7 +16,7 @@
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"
18 18
19namespace Log { 19namespace Common::Log {
20 20
21std::string FormatLogMessage(const Entry& entry) { 21std::string FormatLogMessage(const Entry& entry) {
22 unsigned int time_seconds = static_cast<unsigned int>(entry.timestamp.count() / 1000000); 22 unsigned int time_seconds = static_cast<unsigned int>(entry.timestamp.count() / 1000000);
@@ -108,4 +108,4 @@ void PrintColoredMessage(const Entry& entry) {
108#undef ESC 108#undef ESC
109#endif 109#endif
110} 110}
111} // namespace Log 111} // namespace Common::Log
diff --git a/src/common/logging/text_formatter.h b/src/common/logging/text_formatter.h
index b6d9e57c8..171e74cfe 100644
--- a/src/common/logging/text_formatter.h
+++ b/src/common/logging/text_formatter.h
@@ -7,7 +7,7 @@
7#include <cstddef> 7#include <cstddef>
8#include <string> 8#include <string>
9 9
10namespace Log { 10namespace Common::Log {
11 11
12struct Entry; 12struct Entry;
13 13
@@ -17,4 +17,4 @@ std::string FormatLogMessage(const Entry& entry);
17void PrintMessage(const Entry& entry); 17void PrintMessage(const Entry& entry);
18/// Prints the same message as `PrintMessage`, but colored according to the severity level. 18/// Prints the same message as `PrintMessage`, but colored according to the severity level.
19void PrintColoredMessage(const Entry& entry); 19void PrintColoredMessage(const Entry& entry);
20} // namespace Log 20} // namespace Common::Log
diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp
index 2a5b3f5e7..3a09f74ff 100644
--- a/src/yuzu/configuration/configure_debug.cpp
+++ b/src/yuzu/configuration/configure_debug.cpp
@@ -53,9 +53,9 @@ void ConfigureDebug::ApplyConfiguration() {
53 Settings::values.disable_macro_jit = ui->disable_macro_jit->isChecked(); 53 Settings::values.disable_macro_jit = ui->disable_macro_jit->isChecked();
54 Settings::values.extended_logging = ui->extended_logging->isChecked(); 54 Settings::values.extended_logging = ui->extended_logging->isChecked();
55 Debugger::ToggleConsole(); 55 Debugger::ToggleConsole();
56 Log::Filter filter; 56 Common::Log::Filter filter;
57 filter.ParseFilterString(Settings::values.log_filter); 57 filter.ParseFilterString(Settings::values.log_filter);
58 Log::SetGlobalFilter(filter); 58 Common::Log::SetGlobalFilter(filter);
59} 59}
60 60
61void ConfigureDebug::changeEvent(QEvent* event) { 61void ConfigureDebug::changeEvent(QEvent* event) {
diff --git a/src/yuzu/debugger/console.cpp b/src/yuzu/debugger/console.cpp
index 207ff4d58..c11a326ac 100644
--- a/src/yuzu/debugger/console.cpp
+++ b/src/yuzu/debugger/console.cpp
@@ -29,13 +29,13 @@ void ToggleConsole() {
29 freopen_s(&temp, "CONIN$", "r", stdin); 29 freopen_s(&temp, "CONIN$", "r", stdin);
30 freopen_s(&temp, "CONOUT$", "w", stdout); 30 freopen_s(&temp, "CONOUT$", "w", stdout);
31 freopen_s(&temp, "CONOUT$", "w", stderr); 31 freopen_s(&temp, "CONOUT$", "w", stderr);
32 Log::AddBackend(std::make_unique<Log::ColorConsoleBackend>()); 32 Common::Log::AddBackend(std::make_unique<Common::Log::ColorConsoleBackend>());
33 } 33 }
34 } else { 34 } else {
35 if (FreeConsole()) { 35 if (FreeConsole()) {
36 // In order to close the console, we have to also detach the streams on it. 36 // In order to close the console, we have to also detach the streams on it.
37 // Just redirect them to NUL if there is no console window 37 // Just redirect them to NUL if there is no console window
38 Log::RemoveBackend(Log::ColorConsoleBackend::Name()); 38 Common::Log::RemoveBackend(Common::Log::ColorConsoleBackend::Name());
39 freopen_s(&temp, "NUL", "r", stdin); 39 freopen_s(&temp, "NUL", "r", stdin);
40 freopen_s(&temp, "NUL", "w", stdout); 40 freopen_s(&temp, "NUL", "w", stdout);
41 freopen_s(&temp, "NUL", "w", stderr); 41 freopen_s(&temp, "NUL", "w", stderr);
@@ -43,9 +43,9 @@ void ToggleConsole() {
43 } 43 }
44#else 44#else
45 if (UISettings::values.show_console) { 45 if (UISettings::values.show_console) {
46 Log::AddBackend(std::make_unique<Log::ColorConsoleBackend>()); 46 Common::Log::AddBackend(std::make_unique<Common::Log::ColorConsoleBackend>());
47 } else { 47 } else {
48 Log::RemoveBackend(Log::ColorConsoleBackend::Name()); 48 Common::Log::RemoveBackend(Common::Log::ColorConsoleBackend::Name());
49 } 49 }
50#endif 50#endif
51} 51}
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 23ea4983d..1dfa111e2 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -171,12 +171,14 @@ void GMainWindow::ShowTelemetryCallout() {
171const int GMainWindow::max_recent_files_item; 171const int GMainWindow::max_recent_files_item;
172 172
173static void InitializeLogging() { 173static void InitializeLogging() {
174 using namespace Common;
175
174 Log::Filter log_filter; 176 Log::Filter log_filter;
175 log_filter.ParseFilterString(Settings::values.log_filter); 177 log_filter.ParseFilterString(Settings::values.log_filter);
176 Log::SetGlobalFilter(log_filter); 178 Log::SetGlobalFilter(log_filter);
177 179
178 const std::string& log_dir = Common::FS::GetUserPath(Common::FS::UserPath::LogDir); 180 const std::string& log_dir = FS::GetUserPath(FS::UserPath::LogDir);
179 Common::FS::CreateFullPath(log_dir); 181 FS::CreateFullPath(log_dir);
180 Log::AddBackend(std::make_unique<Log::FileBackend>(log_dir + LOG_FILE)); 182 Log::AddBackend(std::make_unique<Log::FileBackend>(log_dir + LOG_FILE));
181#ifdef _WIN32 183#ifdef _WIN32
182 Log::AddBackend(std::make_unique<Log::DebuggerBackend>()); 184 Log::AddBackend(std::make_unique<Log::DebuggerBackend>());
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
index 982c41785..73a025364 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -74,14 +74,16 @@ static void PrintVersion() {
74} 74}
75 75
76static void InitializeLogging() { 76static void InitializeLogging() {
77 using namespace Common;
78
77 Log::Filter log_filter(Log::Level::Debug); 79 Log::Filter log_filter(Log::Level::Debug);
78 log_filter.ParseFilterString(Settings::values.log_filter); 80 log_filter.ParseFilterString(Settings::values.log_filter);
79 Log::SetGlobalFilter(log_filter); 81 Log::SetGlobalFilter(log_filter);
80 82
81 Log::AddBackend(std::make_unique<Log::ColorConsoleBackend>()); 83 Log::AddBackend(std::make_unique<Log::ColorConsoleBackend>());
82 84
83 const std::string& log_dir = Common::FS::GetUserPath(Common::FS::UserPath::LogDir); 85 const std::string& log_dir = FS::GetUserPath(FS::UserPath::LogDir);
84 Common::FS::CreateFullPath(log_dir); 86 FS::CreateFullPath(log_dir);
85 Log::AddBackend(std::make_unique<Log::FileBackend>(log_dir + LOG_FILE)); 87 Log::AddBackend(std::make_unique<Log::FileBackend>(log_dir + LOG_FILE));
86#ifdef _WIN32 88#ifdef _WIN32
87 Log::AddBackend(std::make_unique<Log::DebuggerBackend>()); 89 Log::AddBackend(std::make_unique<Log::DebuggerBackend>());