diff options
| author | 2021-04-14 21:29:44 -0700 | |
|---|---|---|
| committer | 2021-04-14 21:29:44 -0700 | |
| commit | 60511976bb721415180854a400571433f33e9abe (patch) | |
| tree | dbe65815775e1e9f0179746ef04ce52d893cd667 /src/common/logging/backend.cpp | |
| parent | Merge pull request #6196 from bunnei/asserts-setting (diff) | |
| parent | log/backend: Correct order of const in copy constructor (diff) | |
| download | yuzu-60511976bb721415180854a400571433f33e9abe.tar.gz yuzu-60511976bb721415180854a400571433f33e9abe.tar.xz yuzu-60511976bb721415180854a400571433f33e9abe.zip | |
Merge pull request #6199 from lioncash/log-ns
common/log: Move Log namespace into the Common namespace
Diffstat (limited to 'src/common/logging/backend.cpp')
| -rw-r--r-- | src/common/logging/backend.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 90ee4f33f..bc82905c0 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp | |||
| @@ -25,7 +25,7 @@ | |||
| 25 | #include "common/string_util.h" | 25 | #include "common/string_util.h" |
| 26 | #include "common/threadsafe_queue.h" | 26 | #include "common/threadsafe_queue.h" |
| 27 | 27 | ||
| 28 | namespace Log { | 28 | namespace Common::Log { |
| 29 | 29 | ||
| 30 | /** | 30 | /** |
| 31 | * Static state as a singleton. | 31 | * Static state as a singleton. |
| @@ -37,8 +37,11 @@ public: | |||
| 37 | return backend; | 37 | return backend; |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | Impl(Impl const&) = delete; | 40 | Impl(const Impl&) = delete; |
| 41 | const Impl& operator=(Impl const&) = delete; | 41 | Impl& operator=(const Impl&) = delete; |
| 42 | |||
| 43 | Impl(Impl&&) = delete; | ||
| 44 | Impl& operator=(Impl&&) = delete; | ||
| 42 | 45 | ||
| 43 | void PushEntry(Class log_class, Level log_level, const char* filename, unsigned int line_num, | 46 | void PushEntry(Class log_class, Level log_level, const char* filename, unsigned int line_num, |
| 44 | const char* function, std::string message) { | 47 | const char* function, std::string message) { |
| @@ -132,7 +135,7 @@ private: | |||
| 132 | std::mutex writing_mutex; | 135 | std::mutex writing_mutex; |
| 133 | std::thread backend_thread; | 136 | std::thread backend_thread; |
| 134 | std::vector<std::unique_ptr<Backend>> backends; | 137 | std::vector<std::unique_ptr<Backend>> backends; |
| 135 | Common::MPSCQueue<Log::Entry> message_queue; | 138 | MPSCQueue<Entry> message_queue; |
| 136 | Filter filter; | 139 | Filter filter; |
| 137 | std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()}; | 140 | std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()}; |
| 138 | }; | 141 | }; |
| @@ -146,16 +149,16 @@ void ColorConsoleBackend::Write(const Entry& entry) { | |||
| 146 | } | 149 | } |
| 147 | 150 | ||
| 148 | FileBackend::FileBackend(const std::string& filename) : bytes_written(0) { | 151 | FileBackend::FileBackend(const std::string& filename) : bytes_written(0) { |
| 149 | if (Common::FS::Exists(filename + ".old.txt")) { | 152 | if (FS::Exists(filename + ".old.txt")) { |
| 150 | Common::FS::Delete(filename + ".old.txt"); | 153 | FS::Delete(filename + ".old.txt"); |
| 151 | } | 154 | } |
| 152 | if (Common::FS::Exists(filename)) { | 155 | if (FS::Exists(filename)) { |
| 153 | Common::FS::Rename(filename, filename + ".old.txt"); | 156 | FS::Rename(filename, filename + ".old.txt"); |
| 154 | } | 157 | } |
| 155 | 158 | ||
| 156 | // _SH_DENYWR allows read only access to the file for other programs. | 159 | // _SH_DENYWR allows read only access to the file for other programs. |
| 157 | // It is #defined to 0 on other platforms | 160 | // It is #defined to 0 on other platforms |
| 158 | file = Common::FS::IOFile(filename, "w", _SH_DENYWR); | 161 | file = FS::IOFile(filename, "w", _SH_DENYWR); |
| 159 | } | 162 | } |
| 160 | 163 | ||
| 161 | void FileBackend::Write(const Entry& entry) { | 164 | void FileBackend::Write(const Entry& entry) { |
| @@ -182,7 +185,7 @@ void FileBackend::Write(const Entry& entry) { | |||
| 182 | 185 | ||
| 183 | void DebuggerBackend::Write(const Entry& entry) { | 186 | void DebuggerBackend::Write(const Entry& entry) { |
| 184 | #ifdef _WIN32 | 187 | #ifdef _WIN32 |
| 185 | ::OutputDebugStringW(Common::UTF8ToUTF16W(FormatLogMessage(entry).append(1, '\n')).c_str()); | 188 | ::OutputDebugStringW(UTF8ToUTF16W(FormatLogMessage(entry).append(1, '\n')).c_str()); |
| 186 | #endif | 189 | #endif |
| 187 | } | 190 | } |
| 188 | 191 | ||
| @@ -342,4 +345,4 @@ void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename, | |||
| 342 | instance.PushEntry(log_class, log_level, filename, line_num, function, | 345 | instance.PushEntry(log_class, log_level, filename, line_num, function, |
| 343 | fmt::vformat(format, args)); | 346 | fmt::vformat(format, args)); |
| 344 | } | 347 | } |
| 345 | } // namespace Log | 348 | } // namespace Common::Log |