Merge pull request #6199 from lioncash/log-ns
common/log: Move Log namespace into the Common namespace
This commit is contained in:
commit
83ba604e60
11 changed files with 58 additions and 45 deletions
|
@ -25,7 +25,7 @@
|
|||
#include "common/string_util.h"
|
||||
#include "common/threadsafe_queue.h"
|
||||
|
||||
namespace Log {
|
||||
namespace Common::Log {
|
||||
|
||||
/**
|
||||
* Static state as a singleton.
|
||||
|
@ -37,8 +37,11 @@ public:
|
|||
return backend;
|
||||
}
|
||||
|
||||
Impl(Impl const&) = delete;
|
||||
const Impl& operator=(Impl const&) = delete;
|
||||
Impl(const Impl&) = delete;
|
||||
Impl& operator=(const Impl&) = delete;
|
||||
|
||||
Impl(Impl&&) = delete;
|
||||
Impl& operator=(Impl&&) = delete;
|
||||
|
||||
void PushEntry(Class log_class, Level log_level, const char* filename, unsigned int line_num,
|
||||
const char* function, std::string message) {
|
||||
|
@ -132,7 +135,7 @@ private:
|
|||
std::mutex writing_mutex;
|
||||
std::thread backend_thread;
|
||||
std::vector<std::unique_ptr<Backend>> backends;
|
||||
Common::MPSCQueue<Log::Entry> message_queue;
|
||||
MPSCQueue<Entry> message_queue;
|
||||
Filter filter;
|
||||
std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()};
|
||||
};
|
||||
|
@ -146,16 +149,16 @@ void ColorConsoleBackend::Write(const Entry& entry) {
|
|||
}
|
||||
|
||||
FileBackend::FileBackend(const std::string& filename) : bytes_written(0) {
|
||||
if (Common::FS::Exists(filename + ".old.txt")) {
|
||||
Common::FS::Delete(filename + ".old.txt");
|
||||
if (FS::Exists(filename + ".old.txt")) {
|
||||
FS::Delete(filename + ".old.txt");
|
||||
}
|
||||
if (Common::FS::Exists(filename)) {
|
||||
Common::FS::Rename(filename, filename + ".old.txt");
|
||||
if (FS::Exists(filename)) {
|
||||
FS::Rename(filename, filename + ".old.txt");
|
||||
}
|
||||
|
||||
// _SH_DENYWR allows read only access to the file for other programs.
|
||||
// It is #defined to 0 on other platforms
|
||||
file = Common::FS::IOFile(filename, "w", _SH_DENYWR);
|
||||
file = FS::IOFile(filename, "w", _SH_DENYWR);
|
||||
}
|
||||
|
||||
void FileBackend::Write(const Entry& entry) {
|
||||
|
@ -182,7 +185,7 @@ void FileBackend::Write(const Entry& entry) {
|
|||
|
||||
void DebuggerBackend::Write(const Entry& entry) {
|
||||
#ifdef _WIN32
|
||||
::OutputDebugStringW(Common::UTF8ToUTF16W(FormatLogMessage(entry).append(1, '\n')).c_str());
|
||||
::OutputDebugStringW(UTF8ToUTF16W(FormatLogMessage(entry).append(1, '\n')).c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -342,4 +345,4 @@ void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
|
|||
instance.PushEntry(log_class, log_level, filename, line_num, function,
|
||||
fmt::vformat(format, args));
|
||||
}
|
||||
} // namespace Log
|
||||
} // namespace Common::Log
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue