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.
This commit is contained in:
Lioncash 2023-06-24 01:51:16 +03:00 committed by GPUCode
parent 4fd0cbebdb
commit b4c38372d1
18 changed files with 66 additions and 54 deletions

View File

@ -175,6 +175,8 @@ static void OnStatusMessageReceived(const Network::StatusMessageEntry& msg) {
}
static void InitializeLogging() {
using namespace Common;
Log::Filter log_filter(Log::Level::Debug);
log_filter.ParseFilterString(Settings::values.log_filter.GetValue());
Log::SetGlobalFilter(log_filter);

View File

@ -89,9 +89,9 @@ void ConfigureDebug::ApplyConfiguration() {
UISettings::values.show_console = ui->toggle_console->isChecked();
Settings::values.log_filter = ui->log_filter_edit->text().toStdString();
Debugger::ToggleConsole();
Log::Filter filter;
Common::Log::Filter filter;
filter.ParseFilterString(Settings::values.log_filter.GetValue());
Log::SetGlobalFilter(filter);
Common::Log::SetGlobalFilter(filter);
Settings::values.use_cpu_jit = ui->toggle_cpu_jit->isChecked();
Settings::values.renderer_debug = ui->toggle_renderer_debug->isChecked();

View File

@ -29,13 +29,13 @@ void ToggleConsole() {
freopen_s(&temp, "CONIN$", "r", stdin);
freopen_s(&temp, "CONOUT$", "w", stdout);
freopen_s(&temp, "CONOUT$", "w", stderr);
Log::AddBackend(std::make_unique<Log::ColorConsoleBackend>());
Common::Log::AddBackend(std::make_unique<Common::Log::ColorConsoleBackend>());
}
} else {
if (FreeConsole()) {
// In order to close the console, we have to also detach the streams on it.
// Just redirect them to NUL if there is no console window
Log::RemoveBackend(Log::ColorConsoleBackend::Name());
Common::Log::RemoveBackend(Common::Log::ColorConsoleBackend::Name());
freopen_s(&temp, "NUL", "r", stdin);
freopen_s(&temp, "NUL", "w", stdout);
freopen_s(&temp, "NUL", "w", stderr);

View File

@ -147,6 +147,8 @@ void GMainWindow::ShowTelemetryCallout() {
const int GMainWindow::max_recent_files_item;
static void InitializeLogging() {
using namespace Common;
Log::Filter log_filter;
log_filter.ParseFilterString(Settings::values.log_filter.GetValue());
Log::SetGlobalFilter(log_filter);

View File

@ -22,7 +22,7 @@
#include "common/string_util.h"
#include "common/threadsafe_queue.h"
namespace Log {
namespace Common::Log {
Filter filter;
void SetGlobalFilter(const Filter& f) {
@ -302,4 +302,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

View File

@ -12,7 +12,7 @@
#include "common/logging/filter.h"
#include "common/logging/log.h"
namespace Log {
namespace Common::Log {
/**
* A log entry. Log entries are store in a structured format to permit more varied output
@ -143,4 +143,4 @@ const char* GetLogClassName(Class log_class);
*/
const char* GetLevelName(Level log_level);
} // namespace Log
} // namespace Common::Log

View File

@ -7,7 +7,7 @@
#include "common/logging/filter.h"
#include "common/string_util.h"
namespace Log {
namespace Common::Log {
namespace {
template <typename It>
Level GetLevelByName(const It begin, const It end) {
@ -96,4 +96,4 @@ bool Filter::CheckMessage(Class log_class, Level level) const {
return static_cast<u8>(level) >=
static_cast<u8>(class_levels[static_cast<std::size_t>(log_class)]);
}
} // namespace Log
} // namespace Common::Log

View File

@ -9,4 +9,4 @@
#include <string_view>
#include "common/logging/log.h"
namespace Log {} // namespace Log
namespace Common::Log {} // namespace Common::Log

View File

@ -9,7 +9,7 @@
#include "common/common_types.h"
#include "common/logging/formatter.h"
namespace Log {
namespace Common::Log {
// trims up to and including the last of ../, ..\, src/, src\ in a string
constexpr const char* TrimSourcePath(std::string_view source) {
@ -173,33 +173,39 @@ void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsig
fmt::make_format_args(args...));
}
} // namespace Log
} // namespace Common::Log
// Define the fmt lib macros
#define LOG_GENERIC(log_class, log_level, ...) \
::Log::FmtLogMessage(log_class, log_level, ::Log::TrimSourcePath(__FILE__), __LINE__, \
__func__, __VA_ARGS__)
Common::Log::FmtLogMessage(log_class, log_level, Common::Log::TrimSourcePath(__FILE__), \
__LINE__, __func__, __VA_ARGS__)
#ifdef _DEBUG
#define LOG_TRACE(log_class, ...) \
::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Trace, \
::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__)
Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Trace, \
Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \
__VA_ARGS__)
#else
#define LOG_TRACE(log_class, fmt, ...) (void(0))
#endif
#define LOG_DEBUG(log_class, ...) \
::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Debug, \
::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__)
Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Debug, \
Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \
__VA_ARGS__)
#define LOG_INFO(log_class, ...) \
::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Info, \
::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__)
Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Info, \
Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \
__VA_ARGS__)
#define LOG_WARNING(log_class, ...) \
::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Warning, \
::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__)
Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Warning, \
Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \
__VA_ARGS__)
#define LOG_ERROR(log_class, ...) \
::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Error, \
::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__)
Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Error, \
Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \
__VA_ARGS__)
#define LOG_CRITICAL(log_class, ...) \
::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Critical, \
::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__)
Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Critical, \
Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \
__VA_ARGS__)

View File

@ -18,7 +18,7 @@
#include "common/logging/text_formatter.h"
#include "common/string_util.h"
namespace Log {
namespace Common::Log {
std::string FormatLogMessage(const Entry& entry) {
unsigned int time_seconds = static_cast<unsigned int>(entry.timestamp.count() / 1000000);
@ -141,4 +141,4 @@ void PrintMessageToLogcat([[maybe_unused]] const Entry& entry) {
__android_log_print(android_log_priority, "CitraNative", "%s", str.c_str());
#endif
}
} // namespace Log
} // namespace Common::Log

View File

@ -7,7 +7,7 @@
#include <cstddef>
#include <string>
namespace Log {
namespace Common::Log {
struct Entry;
@ -19,4 +19,4 @@ void PrintMessage(const Entry& entry);
void PrintColoredMessage(const Entry& entry);
/// Formats and prints a log entry to the android logcat.
void PrintMessageToLogcat(const Entry& entry);
} // namespace Log
} // namespace Common::Log

View File

@ -203,7 +203,7 @@ void Process::Run(s32 main_thread_priority, u32 stack_size) {
status = ProcessStatus::Running;
vm_manager.LogLayout(Log::Level::Debug);
vm_manager.LogLayout(Common::Log::Level::Debug);
Kernel::SetupMainThread(kernel, codeset->entrypoint, main_thread_priority, SharedFrom(this));
}

View File

@ -529,7 +529,7 @@ ResultCode SVC::ControlMemory(u32* out_addr, u32 addr0, u32 addr1, u32 size, u32
return ERR_INVALID_COMBINATION;
}
process.vm_manager.LogLayout(Log::Level::Trace);
process.vm_manager.LogLayout(Common::Log::Level::Trace);
return RESULT_SUCCESS;
}

View File

@ -239,10 +239,10 @@ ResultCode VMManager::ReprotectRange(VAddr target, u32 size, VMAPermission new_p
return RESULT_SUCCESS;
}
void VMManager::LogLayout(Log::Level log_level) const {
void VMManager::LogLayout(Common::Log::Level log_level) const {
for (const auto& p : vma_map) {
const VirtualMemoryArea& vma = p.second;
LOG_GENERIC(::Log::Class::Kernel, log_level, "{:08X} - {:08X} size: {:8X} {}{}{} {}",
LOG_GENERIC(Common::Log::Class::Kernel, log_level, "{:08X} - {:08X} size: {:8X} {}{}{} {}",
vma.base, vma.base + vma.size, vma.size,
(u8)vma.permissions & (u8)VMAPermission::Read ? 'R' : '-',
(u8)vma.permissions & (u8)VMAPermission::Write ? 'W' : '-',

View File

@ -202,7 +202,7 @@ public:
ResultCode ReprotectRange(VAddr target, u32 size, VMAPermission new_perms);
/// Dumps the address space layout to the log, for debugging
void LogLayout(Log::Level log_level) const;
void LogLayout(Common::Log::Level log_level) const;
/// Gets a list of backing memory blocks for the specified range
ResultVal<std::vector<std::pair<MemoryRef, u32>>> GetBackingBlocksForRange(VAddr address,

View File

@ -150,6 +150,8 @@ static void SaveBanList(const Network::Room::BanList& ban_list, const std::strin
}
static void InitializeLogging(const std::string& log_file) {
using namespace Common;
Log::AddBackend(std::make_unique<Log::ColorConsoleBackend>());
const std::string& log_dir = FileUtil::GetUserPath(FileUtil::UserPath::LogDir);

View File

@ -56,22 +56,22 @@ inline std::string_view GetType(GLenum type) {
static void APIENTRY DebugHandler(GLenum source, GLenum type, GLuint id, GLenum severity,
GLsizei length, const GLchar* message, const void* user_param) {
Log::Level level = Log::Level::Info;
auto level = Common::Log::Level::Info;
switch (severity) {
case GL_DEBUG_SEVERITY_HIGH:
level = Log::Level::Critical;
level = Common::Log::Level::Critical;
break;
case GL_DEBUG_SEVERITY_MEDIUM:
level = Log::Level::Warning;
level = Common::Log::Level::Warning;
break;
case GL_DEBUG_SEVERITY_NOTIFICATION:
case GL_DEBUG_SEVERITY_LOW:
level = Log::Level::Debug;
level = Common::Log::Level::Debug;
break;
}
LOG_GENERIC(Log::Class::Render_OpenGL, level, "{} {} {}: {}", GetSource(source), GetType(type),
id, message);
LOG_GENERIC(Common::Log::Class::Render_OpenGL, level, "{} {} {}: {}", GetSource(source),
GetType(type), id, message);
}
Driver::Driver(Core::TelemetrySession& telemetry_session_)

View File

@ -38,23 +38,23 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL DebugUtilsCallback(
break;
}
Log::Level level{};
Common::Log::Level level{};
switch (severity) {
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT:
level = Log::Level::Error;
level = Common::Log::Level::Error;
break;
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT:
level = Log::Level::Info;
level = Common::Log::Level::Info;
break;
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT:
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT:
level = Log::Level::Debug;
level = Common::Log::Level::Debug;
break;
default:
level = Log::Level::Info;
level = Common::Log::Level::Info;
}
LOG_GENERIC(Log::Class::Render_Vulkan, level, "{}: {}",
LOG_GENERIC(Common::Log::Class::Render_Vulkan, level, "{}: {}",
callback_data->pMessageIdName ? callback_data->pMessageIdName : "<null>",
callback_data->pMessage ? callback_data->pMessage : "<null>");
@ -69,25 +69,25 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback(VkDebugReportFlagsEXT
const char* pMessage, void* pUserData) {
const VkDebugReportFlagBitsEXT severity = static_cast<VkDebugReportFlagBitsEXT>(flags);
Log::Level level{};
Common::Log::Level level{};
switch (severity) {
case VK_DEBUG_REPORT_ERROR_BIT_EXT:
level = Log::Level::Error;
level = Common::Log::Level::Error;
break;
case VK_DEBUG_REPORT_INFORMATION_BIT_EXT:
level = Log::Level::Warning;
level = Common::Log::Level::Warning;
break;
case VK_DEBUG_REPORT_DEBUG_BIT_EXT:
case VK_DEBUG_REPORT_WARNING_BIT_EXT:
case VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT:
level = Log::Level::Debug;
level = Common::Log::Level::Debug;
break;
default:
level = Log::Level::Info;
level = Common::Log::Level::Info;
}
const vk::DebugReportObjectTypeEXT type = static_cast<vk::DebugReportObjectTypeEXT>(objectType);
LOG_GENERIC(Log::Class::Render_Vulkan, level,
LOG_GENERIC(Common::Log::Class::Render_Vulkan, level,
"type = {}, object = {} | MessageCode = {:#x}, LayerPrefix = {} | {}",
vk::to_string(type), object, messageCode, pLayerPrefix, pMessage);