Log: Switch to enum class
Some checks failed
Create rolling release / windows-build (push) Waiting to run
Create rolling release / windows-arm64-build (push) Waiting to run
Create rolling release / macos-build (push) Waiting to run
Create rolling release / create-release (push) Blocked by required conditions
Create rolling release / linux-build (push) Failing after 0s
Create rolling release / linux-flatpak-build (push) Failing after 0s

Need to change the channel to a bitset too.. the string lookups are
horribly slow, and conflict when one is a prefix of another.
This commit is contained in:
Stenzek 2024-09-21 21:49:38 +10:00
parent 88381209b3
commit 3dca598063
No known key found for this signature in database
146 changed files with 291 additions and 291 deletions

View File

@ -22,7 +22,7 @@
#endif
#endif
Log_SetChannel(DynamicLibrary);
LOG_CHANNEL(DynamicLibrary);
DynamicLibrary::DynamicLibrary() = default;

View File

@ -45,7 +45,7 @@
#include <unistd.h>
#endif
Log_SetChannel(FileSystem);
LOG_CHANNEL(FileSystem);
#ifndef __ANDROID__

View File

@ -38,30 +38,30 @@ static void RegisterCallback(CallbackFunctionType callbackFunction, void* pUserP
const std::unique_lock<std::mutex>& lock);
static void UnregisterCallback(CallbackFunctionType callbackFunction, void* pUserParam,
const std::unique_lock<std::mutex>& lock);
static bool FilterTest(LOGLEVEL level, const char* channelName, const std::unique_lock<std::mutex>& lock);
static void ExecuteCallbacks(const char* channelName, const char* functionName, LOGLEVEL level,
std::string_view message, const std::unique_lock<std::mutex>& lock);
static bool FilterTest(Level level, const char* channelName, const std::unique_lock<std::mutex>& lock);
static void ExecuteCallbacks(const char* channelName, const char* functionName, Level level, std::string_view message,
const std::unique_lock<std::mutex>& lock);
static void FormatLogMessageForDisplay(fmt::memory_buffer& buffer, const char* channelName, const char* functionName,
LOGLEVEL level, std::string_view message, bool timestamp, bool ansi_color_code,
Level level, std::string_view message, bool timestamp, bool ansi_color_code,
bool newline);
static void ConsoleOutputLogCallback(void* pUserParam, const char* channelName, const char* functionName,
LOGLEVEL level, std::string_view message);
static void DebugOutputLogCallback(void* pUserParam, const char* channelName, const char* functionName, LOGLEVEL level,
static void ConsoleOutputLogCallback(void* pUserParam, const char* channelName, const char* functionName, Level level,
std::string_view message);
static void DebugOutputLogCallback(void* pUserParam, const char* channelName, const char* functionName, Level level,
std::string_view message);
static void FileOutputLogCallback(void* pUserParam, const char* channelName, const char* functionName, LOGLEVEL level,
static void FileOutputLogCallback(void* pUserParam, const char* channelName, const char* functionName, Level level,
std::string_view message);
template<typename T>
static void FormatLogMessageAndPrint(const char* channelName, const char* functionName, LOGLEVEL level,
static void FormatLogMessageAndPrint(const char* channelName, const char* functionName, Level level,
std::string_view message, bool timestamp, bool ansi_color_code, bool newline,
const T& callback);
#ifdef _WIN32
template<typename T>
static void FormatLogMessageAndPrintW(const char* channelName, const char* functionName, LOGLEVEL level,
static void FormatLogMessageAndPrintW(const char* channelName, const char* functionName, Level level,
std::string_view message, bool timestamp, bool ansi_color_code, bool newline,
const T& callback);
#endif
static const char s_log_level_characters[LOGLEVEL_COUNT] = {'X', 'E', 'W', 'I', 'V', 'D', 'B', 'T'};
static const char s_log_level_characters[static_cast<size_t>(Level::Count)] = {'X', 'E', 'W', 'I', 'V', 'D', 'B', 'T'};
static std::vector<RegisteredCallback> s_callbacks;
static std::mutex s_callback_mutex;
@ -69,9 +69,9 @@ static std::mutex s_callback_mutex;
static Common::Timer::Value s_start_timestamp = Common::Timer::GetCurrentValue();
static std::string s_log_filter;
static LOGLEVEL s_log_level = LOGLEVEL_TRACE;
static Level s_log_level = Level::None;
static bool s_console_output_enabled = false;
static bool s_console_output_timestamps = true;
static bool s_console_output_timestamps = false;
static bool s_file_output_enabled = false;
static bool s_file_output_timestamp = false;
static bool s_debug_output_enabled = false;
@ -154,7 +154,7 @@ bool Log::IsDebugOutputEnabled()
return s_debug_output_enabled;
}
void Log::ExecuteCallbacks(const char* channelName, const char* functionName, LOGLEVEL level, std::string_view message,
void Log::ExecuteCallbacks(const char* channelName, const char* functionName, Level level, std::string_view message,
const std::unique_lock<std::mutex>& lock)
{
for (RegisteredCallback& callback : s_callbacks)
@ -162,22 +162,22 @@ void Log::ExecuteCallbacks(const char* channelName, const char* functionName, LO
}
ALWAYS_INLINE_RELEASE void Log::FormatLogMessageForDisplay(fmt::memory_buffer& buffer, const char* channelName,
const char* functionName, LOGLEVEL level,
const char* functionName, Level level,
std::string_view message, bool timestamp,
bool ansi_color_code, bool newline)
{
static constexpr std::string_view s_ansi_color_codes[LOGLEVEL_COUNT] = {
"\033[0m"sv, // NONE
"\033[1;31m"sv, // ERROR
"\033[1;33m"sv, // WARNING
"\033[1;37m"sv, // INFO
"\033[1;32m"sv, // VERBOSE
"\033[0;37m"sv, // DEV
"\033[0;32m"sv, // DEBUG
"\033[0;34m"sv, // TRACE
static constexpr std::string_view s_ansi_color_codes[static_cast<size_t>(Level::Count)] = {
"\033[0m"sv, // None
"\033[1;31m"sv, // Error
"\033[1;33m"sv, // Warning
"\033[1;37m"sv, // Info
"\033[1;32m"sv, // Verbose
"\033[0;37m"sv, // Dev
"\033[0;32m"sv, // Debug
"\033[0;34m"sv, // Trace
};
std::string_view color_start = ansi_color_code ? s_ansi_color_codes[level] : ""sv;
std::string_view color_start = ansi_color_code ? s_ansi_color_codes[static_cast<size_t>(level)] : ""sv;
std::string_view color_end = ansi_color_code ? s_ansi_color_codes[0] : ""sv;
std::string_view message_end = newline ? "\n"sv : ""sv;
@ -190,34 +190,34 @@ ALWAYS_INLINE_RELEASE void Log::FormatLogMessageForDisplay(fmt::memory_buffer& b
if (functionName)
{
fmt::format_to(appender, "[{:10.4f}] {}{}({}): {}{}{}", message_time, color_start, s_log_level_characters[level],
functionName, message, color_end, message_end);
fmt::format_to(appender, "[{:10.4f}] {}{}({}): {}{}{}", message_time, color_start,
s_log_level_characters[static_cast<size_t>(level)], functionName, message, color_end, message_end);
}
else
{
fmt::format_to(appender, "[{:10.4f}] {}{}/{}: {}{}{}", message_time, color_start, s_log_level_characters[level],
channelName, message, color_end, message_end);
fmt::format_to(appender, "[{:10.4f}] {}{}/{}: {}{}{}", message_time, color_start,
s_log_level_characters[static_cast<size_t>(level)], channelName, message, color_end, message_end);
}
}
else
{
if (functionName)
{
fmt::format_to(appender, "{}{}({}): {}{}{}", color_start, s_log_level_characters[level], functionName, message,
color_end, message_end);
fmt::format_to(appender, "{}{}({}): {}{}{}", color_start, s_log_level_characters[static_cast<size_t>(level)],
functionName, message, color_end, message_end);
}
else
{
fmt::format_to(appender, "{}{}/{}: {}{}{}", color_start, s_log_level_characters[level], channelName, message,
color_end, message_end);
fmt::format_to(appender, "{}{}/{}: {}{}{}", color_start, s_log_level_characters[static_cast<size_t>(level)],
channelName, message, color_end, message_end);
}
}
}
template<typename T>
ALWAYS_INLINE_RELEASE void Log::FormatLogMessageAndPrint(const char* channelName, const char* functionName,
LOGLEVEL level, std::string_view message, bool timestamp,
bool ansi_color_code, bool newline, const T& callback)
ALWAYS_INLINE_RELEASE void Log::FormatLogMessageAndPrint(const char* channelName, const char* functionName, Level level,
std::string_view message, bool timestamp, bool ansi_color_code,
bool newline, const T& callback)
{
fmt::memory_buffer buffer;
Log::FormatLogMessageForDisplay(buffer, channelName, functionName, level, message, timestamp, ansi_color_code,
@ -229,7 +229,7 @@ ALWAYS_INLINE_RELEASE void Log::FormatLogMessageAndPrint(const char* channelName
template<typename T>
ALWAYS_INLINE_RELEASE void Log::FormatLogMessageAndPrintW(const char* channelName, const char* functionName,
LOGLEVEL level, std::string_view message, bool timestamp,
Level level, std::string_view message, bool timestamp,
bool ansi_color_code, bool newline, const T& callback)
{
fmt::memory_buffer buffer;
@ -274,7 +274,7 @@ static bool EnableVirtualTerminalProcessing(HANDLE hConsole)
#endif
void Log::ConsoleOutputLogCallback(void* pUserParam, const char* channelName, const char* functionName, LOGLEVEL level,
void Log::ConsoleOutputLogCallback(void* pUserParam, const char* channelName, const char* functionName, Level level,
std::string_view message)
{
if (!s_console_output_enabled)
@ -283,7 +283,7 @@ void Log::ConsoleOutputLogCallback(void* pUserParam, const char* channelName, co
#if defined(_WIN32)
FormatLogMessageAndPrintW(channelName, functionName, level, message, s_console_output_timestamps, true, true,
[level](const std::wstring_view& message) {
HANDLE hOutput = (level <= LOGLEVEL_WARNING) ? s_hConsoleStdErr : s_hConsoleStdOut;
HANDLE hOutput = (level <= Level::Warning) ? s_hConsoleStdErr : s_hConsoleStdOut;
DWORD chars_written;
WriteConsoleW(hOutput, message.data(), static_cast<DWORD>(message.length()),
&chars_written, nullptr);
@ -291,13 +291,13 @@ void Log::ConsoleOutputLogCallback(void* pUserParam, const char* channelName, co
#elif !defined(__ANDROID__)
FormatLogMessageAndPrint(channelName, functionName, level, message, s_console_output_timestamps, true, true,
[level](std::string_view message) {
const int outputFd = (level <= LOGLEVEL_WARNING) ? STDERR_FILENO : STDOUT_FILENO;
const int outputFd = (level <= Log::Level::Warning) ? STDERR_FILENO : STDOUT_FILENO;
write(outputFd, message.data(), message.length());
});
#endif
}
void Log::DebugOutputLogCallback(void* pUserParam, const char* channelName, const char* functionName, LOGLEVEL level,
void Log::DebugOutputLogCallback(void* pUserParam, const char* channelName, const char* functionName, Level level,
std::string_view message)
{
if (!s_debug_output_enabled)
@ -310,21 +310,19 @@ void Log::DebugOutputLogCallback(void* pUserParam, const char* channelName, cons
if (message.empty())
return;
static constexpr int logPriority[LOGLEVEL_COUNT] = {
ANDROID_LOG_INFO, // NONE
ANDROID_LOG_ERROR, // ERROR
ANDROID_LOG_WARN, // WARNING
ANDROID_LOG_INFO, // PERF
ANDROID_LOG_INFO, // INFO
ANDROID_LOG_INFO, // VERBOSE
ANDROID_LOG_DEBUG, // DEV
ANDROID_LOG_DEBUG, // PROFILE
ANDROID_LOG_DEBUG, // DEBUG
ANDROID_LOG_DEBUG, // TRACE
static constexpr int logPriority[static_cast<size_t>(Level::Count)] = {
ANDROID_LOG_INFO, // None
ANDROID_LOG_ERROR, // Error
ANDROID_LOG_WARN, // Warning
ANDROID_LOG_INFO, // Info
ANDROID_LOG_INFO, // Verbose
ANDROID_LOG_DEBUG, // Dev
ANDROID_LOG_DEBUG, // Debug
ANDROID_LOG_DEBUG, // Trace
};
__android_log_print(logPriority[level], channelName, "%.*s", static_cast<int>(message.length()), message.data());
#else
__android_log_print(logPriority[static_cast<size_t>(level)], channelName, "%.*s", static_cast<int>(message.length()),
message.data());
#endif
}
@ -421,7 +419,7 @@ void Log::SetDebugOutputParams(bool enabled)
UnregisterCallback(DebugOutputLogCallback, nullptr, lock);
}
void Log::FileOutputLogCallback(void* pUserParam, const char* channelName, const char* functionName, LOGLEVEL level,
void Log::FileOutputLogCallback(void* pUserParam, const char* channelName, const char* functionName, Level level,
std::string_view message)
{
if (!s_file_output_enabled)
@ -444,7 +442,7 @@ void Log::SetFileOutputParams(bool enabled, const char* filename, bool timestamp
s_file_handle.reset(FileSystem::OpenCFile(filename, "wb"));
if (!s_file_handle) [[unlikely]]
{
ExecuteCallbacks("Log", __FUNCTION__, LOGLEVEL_ERROR,
ExecuteCallbacks("Log", __FUNCTION__, Level::Error,
TinyString::from_format("Failed to open log file '{}'", filename), lock);
return;
}
@ -461,12 +459,12 @@ void Log::SetFileOutputParams(bool enabled, const char* filename, bool timestamp
s_file_output_timestamp = timestamps;
}
LOGLEVEL Log::GetLogLevel()
Log::Level Log::GetLogLevel()
{
return s_log_level;
}
bool Log::IsLogVisible(LOGLEVEL level, const char* channelName)
bool Log::IsLogVisible(Level level, const char* channelName)
{
if (level > s_log_level)
return false;
@ -475,10 +473,10 @@ bool Log::IsLogVisible(LOGLEVEL level, const char* channelName)
return FilterTest(level, channelName, lock);
}
void Log::SetLogLevel(LOGLEVEL level)
void Log::SetLogLevel(Level level)
{
std::unique_lock lock(s_callback_mutex);
DebugAssert(level < LOGLEVEL_COUNT);
DebugAssert(level < Level::Count);
s_log_level = level;
}
@ -489,13 +487,13 @@ void Log::SetLogFilter(std::string_view filter)
s_log_filter = filter;
}
ALWAYS_INLINE_RELEASE bool Log::FilterTest(LOGLEVEL level, const char* channelName,
ALWAYS_INLINE_RELEASE bool Log::FilterTest(Level level, const char* channelName,
const std::unique_lock<std::mutex>& lock)
{
return (level <= s_log_level && s_log_filter.find(channelName) == std::string::npos);
}
void Log::Write(const char* channelName, LOGLEVEL level, std::string_view message)
void Log::Write(const char* channelName, Level level, std::string_view message)
{
std::unique_lock lock(s_callback_mutex);
if (!FilterTest(level, channelName, lock))
@ -504,7 +502,7 @@ void Log::Write(const char* channelName, LOGLEVEL level, std::string_view messag
ExecuteCallbacks(channelName, nullptr, level, message, lock);
}
void Log::Write(const char* channelName, const char* functionName, LOGLEVEL level, std::string_view message)
void Log::Write(const char* channelName, const char* functionName, Level level, std::string_view message)
{
std::unique_lock lock(s_callback_mutex);
if (!FilterTest(level, channelName, lock))
@ -513,7 +511,7 @@ void Log::Write(const char* channelName, const char* functionName, LOGLEVEL leve
ExecuteCallbacks(channelName, functionName, level, message, lock);
}
void Log::WriteFmtArgs(const char* channelName, LOGLEVEL level, fmt::string_view fmt, fmt::format_args args)
void Log::WriteFmtArgs(const char* channelName, Level level, fmt::string_view fmt, fmt::format_args args)
{
std::unique_lock lock(s_callback_mutex);
if (!FilterTest(level, channelName, lock))
@ -525,7 +523,7 @@ void Log::WriteFmtArgs(const char* channelName, LOGLEVEL level, fmt::string_view
ExecuteCallbacks(channelName, nullptr, level, std::string_view(buffer.data(), buffer.size()), lock);
}
void Log::WriteFmtArgs(const char* channelName, const char* functionName, LOGLEVEL level, fmt::string_view fmt,
void Log::WriteFmtArgs(const char* channelName, const char* functionName, Level level, fmt::string_view fmt,
fmt::format_args args)
{
std::unique_lock lock(s_callback_mutex);

View File

@ -12,24 +12,24 @@
#include <mutex>
#include <string_view>
enum LOGLEVEL
namespace Log {
enum class Level
{
LOGLEVEL_NONE, // Silences all log traffic
LOGLEVEL_ERROR,
LOGLEVEL_WARNING,
LOGLEVEL_INFO,
LOGLEVEL_VERBOSE,
LOGLEVEL_DEV,
LOGLEVEL_DEBUG,
LOGLEVEL_TRACE,
None, // Silences all log traffic
Error,
Warning,
Info,
Verbose,
Dev,
Debug,
Trace,
LOGLEVEL_COUNT
Count
};
namespace Log {
// log message callback type
using CallbackFunctionType = void (*)(void* pUserParam, const char* channelName, const char* functionName,
LOGLEVEL level, std::string_view message);
using CallbackFunctionType = void (*)(void* pUserParam, const char* channelName, const char* functionName, Level level,
std::string_view message);
// registers a log callback
void RegisterCallback(CallbackFunctionType callbackFunction, void* pUserParam);
@ -53,43 +53,43 @@ void SetDebugOutputParams(bool enabled);
void SetFileOutputParams(bool enabled, const char* filename, bool timestamps = true);
// Returns the current global filtering level.
LOGLEVEL GetLogLevel();
Level GetLogLevel();
// Returns true if log messages for the specified log level/filter would not be filtered (and visible).
bool IsLogVisible(LOGLEVEL level, const char* channelName);
bool IsLogVisible(Level level, const char* channelName);
// Sets global filtering level, messages below this level won't be sent to any of the logging sinks.
void SetLogLevel(LOGLEVEL level);
void SetLogLevel(Level level);
// Sets global filter, any messages from these channels won't be sent to any of the logging sinks.
void SetLogFilter(std::string_view filter);
// writes a message to the log
void Write(const char* channelName, LOGLEVEL level, std::string_view message);
void Write(const char* channelName, const char* functionName, LOGLEVEL level, std::string_view message);
void WriteFmtArgs(const char* channelName, LOGLEVEL level, fmt::string_view fmt, fmt::format_args args);
void WriteFmtArgs(const char* channelName, const char* functionName, LOGLEVEL level, fmt::string_view fmt,
void Write(const char* channelName, Level level, std::string_view message);
void Write(const char* channelName, const char* functionName, Level level, std::string_view message);
void WriteFmtArgs(const char* channelName, Level level, fmt::string_view fmt, fmt::format_args args);
void WriteFmtArgs(const char* channelName, const char* functionName, Level level, fmt::string_view fmt,
fmt::format_args args);
ALWAYS_INLINE static void FastWrite(const char* channelName, LOGLEVEL level, std::string_view message)
ALWAYS_INLINE static void FastWrite(const char* channelName, Level level, std::string_view message)
{
if (level <= GetLogLevel()) [[unlikely]]
Write(channelName, level, message);
}
ALWAYS_INLINE static void FastWrite(const char* channelName, const char* functionName, LOGLEVEL level,
ALWAYS_INLINE static void FastWrite(const char* channelName, const char* functionName, Level level,
std::string_view message)
{
if (level <= GetLogLevel()) [[unlikely]]
Write(channelName, functionName, level, message);
}
template<typename... T>
ALWAYS_INLINE static void FastWrite(const char* channelName, LOGLEVEL level, fmt::format_string<T...> fmt, T&&... args)
ALWAYS_INLINE static void FastWrite(const char* channelName, Level level, fmt::format_string<T...> fmt, T&&... args)
{
if (level <= GetLogLevel()) [[unlikely]]
WriteFmtArgs(channelName, level, fmt, fmt::make_format_args(args...));
}
template<typename... T>
ALWAYS_INLINE static void FastWrite(const char* channelName, const char* functionName, LOGLEVEL level,
ALWAYS_INLINE static void FastWrite(const char* channelName, const char* functionName, Level level,
fmt::format_string<T...> fmt, T&&... args)
{
if (level <= GetLogLevel()) [[unlikely]]
@ -98,17 +98,17 @@ ALWAYS_INLINE static void FastWrite(const char* channelName, const char* functio
} // namespace Log
// log wrappers
#define Log_SetChannel(ChannelName) [[maybe_unused]] static const char* ___LogChannel___ = #ChannelName;
#define LOG_CHANNEL(name) [[maybe_unused]] static const char* ___LogChannel___ = #name;
#define ERROR_LOG(...) Log::FastWrite(___LogChannel___, __func__, LOGLEVEL_ERROR, __VA_ARGS__)
#define WARNING_LOG(...) Log::FastWrite(___LogChannel___, __func__, LOGLEVEL_WARNING, __VA_ARGS__)
#define INFO_LOG(...) Log::FastWrite(___LogChannel___, LOGLEVEL_INFO, __VA_ARGS__)
#define VERBOSE_LOG(...) Log::FastWrite(___LogChannel___, LOGLEVEL_VERBOSE, __VA_ARGS__)
#define DEV_LOG(...) Log::FastWrite(___LogChannel___, LOGLEVEL_DEV, __VA_ARGS__)
#define ERROR_LOG(...) Log::FastWrite(___LogChannel___, __func__, Log::Level::Error, __VA_ARGS__)
#define WARNING_LOG(...) Log::FastWrite(___LogChannel___, __func__, Log::Level::Warning, __VA_ARGS__)
#define INFO_LOG(...) Log::FastWrite(___LogChannel___, Log::Level::Info, __VA_ARGS__)
#define VERBOSE_LOG(...) Log::FastWrite(___LogChannel___, Log::Level::Verbose, __VA_ARGS__)
#define DEV_LOG(...) Log::FastWrite(___LogChannel___, Log::Level::Dev, __VA_ARGS__)
#ifdef _DEBUG
#define DEBUG_LOG(...) Log::FastWrite(___LogChannel___, LOGLEVEL_DEBUG, __VA_ARGS__)
#define TRACE_LOG(...) Log::FastWrite(___LogChannel___, LOGLEVEL_TRACE, __VA_ARGS__)
#define DEBUG_LOG(...) Log::FastWrite(___LogChannel___, Log::Level::Debug, __VA_ARGS__)
#define TRACE_LOG(...) Log::FastWrite(___LogChannel___, Log::Level::Trace, __VA_ARGS__)
#else
#define DEBUG_LOG(...) \
do \

View File

@ -35,7 +35,7 @@
#include <unistd.h>
#endif
Log_SetChannel(MemMap);
LOG_CHANNEL(MemMap);
namespace MemMap {
/// Allocates RWX memory at the specified address.

View File

@ -9,7 +9,7 @@
#include <cstdio>
#include <limits>
Log_SetChannel(ProgressCallback);
LOG_CHANNEL(ProgressCallback);
static ProgressCallback s_nullProgressCallbacks;
ProgressCallback* ProgressCallback::NullProgressCallback = &s_nullProgressCallbacks;

View File

@ -41,7 +41,7 @@
#endif
#endif
Log_SetChannel(Threading);
LOG_CHANNEL(Threading);
#ifdef _WIN32
union FileTimeU64Union

View File

@ -52,7 +52,7 @@
#include <unordered_set>
#include <vector>
Log_SetChannel(Achievements);
LOG_CHANNEL(Achievements);
#ifdef ENABLE_RAINTEGRATION
// RA_Interface ends up including windows.h, with its silly macros.

View File

@ -20,7 +20,7 @@
#include <cmath>
Log_SetChannel(AnalogController);
LOG_CHANNEL(AnalogController);
AnalogController::AnalogController(u32 index) : Controller(index)
{

View File

@ -16,7 +16,7 @@
#include "IconsPromptFont.h"
#include "fmt/format.h"
Log_SetChannel(AnalogJoystick);
LOG_CHANNEL(AnalogJoystick);
AnalogJoystick::AnalogJoystick(u32 index) : Controller(index)
{

View File

@ -15,7 +15,7 @@
#include "common/path.h"
#include "common/string_util.h"
Log_SetChannel(BIOS);
LOG_CHANNEL(BIOS);
namespace BIOS {
static const ImageInfo* GetInfoForHash(const std::span<u8> image, const ImageInfo::Hash& hash);

View File

@ -38,7 +38,7 @@
#include <tuple>
#include <utility>
Log_SetChannel(Bus);
LOG_CHANNEL(Bus);
// TODO: Get rid of page code bits, instead use page faults to track SMC.
@ -933,7 +933,7 @@ void Bus::AddTTYCharacter(char ch)
{
if (!s_tty_line_buffer.empty())
{
Log::FastWrite("TTY", "", LOGLEVEL_INFO, "\033[1;34m{}\033[0m", s_tty_line_buffer);
Log::FastWrite("TTY", "", Log::Level::Info, "\033[1;34m{}\033[0m", s_tty_line_buffer);
#ifdef _DEBUG
if (CPU::IsTraceEnabled())
CPU::WriteToExecutionLog("TTY: %s\n", s_tty_line_buffer.c_str());

View File

@ -32,7 +32,7 @@
#include <map>
#include <vector>
Log_SetChannel(CDROM);
LOG_CHANNEL(CDROM);
namespace CDROM {
namespace {
@ -1621,7 +1621,7 @@ void CDROM::EndCommand()
void CDROM::ExecuteCommand(void*, TickCount ticks, TickCount ticks_late)
{
const CommandInfo& ci = s_command_info[static_cast<u8>(s_command)];
if (Log::IsLogVisible(LOGLEVEL_DEV, ___LogChannel___)) [[unlikely]]
if (Log::IsLogVisible(Log::Level::Dev, ___LogChannel___)) [[unlikely]]
{
SmallString params;
for (u32 i = 0; i < s_param_fifo.GetSize(); i++)

View File

@ -5,7 +5,7 @@
#include "common/assert.h"
#include "common/log.h"
#include "common/timer.h"
Log_SetChannel(CDROMAsyncReader);
LOG_CHANNEL(CDROMAsyncReader);
CDROMAsyncReader::CDROMAsyncReader() = default;

View File

@ -18,7 +18,7 @@
#include <sstream>
#include <type_traits>
Log_SetChannel(Cheats);
LOG_CHANNEL(Cheats);
static std::array<u32, 256> cht_register; // Used for D7 ,51 & 52 cheat types

View File

@ -21,7 +21,7 @@
#include "common/log.h"
#include "common/memmap.h"
Log_SetChannel(CPU::CodeCache);
LOG_CHANNEL(CPU::CodeCache);
// Enable dumping of recompiled block code size statistics.
// #define DUMP_CODE_SIZE_STATS 1

View File

@ -26,7 +26,7 @@
#include <cstdio>
Log_SetChannel(CPU::Core);
LOG_CHANNEL(CPU::Core);
namespace CPU {
enum class ExecutionBreakType

View File

@ -15,7 +15,7 @@
#include <cstdint>
#include <limits>
Log_SetChannel(NewRec::Compiler);
LOG_CHANNEL(NewRec::Compiler);
// TODO: direct link skip delay slot check
// TODO: speculative constants

View File

@ -19,7 +19,7 @@
#ifdef CPU_ARCH_ARM32
Log_SetChannel(CPU::NewRec);
LOG_CHANNEL(CPU::NewRec);
#define PTR(x) vixl::aarch32::MemOperand(RSTATE, (((u8*)(x)) - ((u8*)&g_state)))
#define RMEMBASE vixl::aarch32::r3

View File

@ -19,7 +19,7 @@
#ifdef CPU_ARCH_ARM64
Log_SetChannel(CPU::NewRec);
LOG_CHANNEL(CPU::NewRec);
#define PTR(x) vixl::aarch64::MemOperand(RSTATE, (((u8*)(x)) - ((u8*)&g_state)))

View File

@ -20,7 +20,7 @@
#ifdef CPU_ARCH_RISCV64
Log_SetChannel(CPU::NewRec);
LOG_CHANNEL(CPU::NewRec);
#ifdef ENABLE_HOST_DISASSEMBLY
extern "C" {

View File

@ -20,7 +20,7 @@
#ifdef CPU_ARCH_X64
Log_SetChannel(CPU::NewRec);
LOG_CHANNEL(CPU::NewRec);
#define RMEMBASE cg->rbx
#define RSTATE cg->rbp

View File

@ -19,7 +19,7 @@
#include <climits>
#include <cmath>
Log_SetChannel(CPU::PGXP);
LOG_CHANNEL(CPU::PGXP);
// #define LOG_VALUES 1
// #define LOG_LOOKUPS 1

View File

@ -11,7 +11,7 @@
#include "common/log.h"
Log_SetChannel(CPU::Recompiler);
LOG_CHANNEL(CPU::Recompiler);
// TODO: Turn load+sext/zext into a single signed/unsigned load
// TODO: mulx/shlx/etc

View File

@ -16,7 +16,7 @@
#ifdef CPU_ARCH_ARM32
Log_SetChannel(CPU::Recompiler);
LOG_CHANNEL(CPU::Recompiler);
#ifdef ENABLE_HOST_DISASSEMBLY
#include "vixl/aarch32/disasm-aarch32.h"

View File

@ -16,7 +16,7 @@
#ifdef CPU_ARCH_ARM64
Log_SetChannel(CPU::Recompiler);
LOG_CHANNEL(CPU::Recompiler);
#ifdef ENABLE_HOST_DISASSEMBLY
#include "vixl/aarch64/disasm-aarch64.h"

View File

@ -8,7 +8,7 @@
#include "common/log.h"
Log_SetChannel(Recompiler::CodeGenerator);
LOG_CHANNEL(Recompiler::CodeGenerator);
namespace CPU::Recompiler {

View File

@ -16,7 +16,7 @@
#ifdef CPU_ARCH_X64
Log_SetChannel(Recompiler::CodeGenerator);
LOG_CHANNEL(Recompiler::CodeGenerator);
#ifdef ENABLE_HOST_DISASSEMBLY
#include "Zycore/Format.h"
@ -260,7 +260,7 @@ void CPU::CodeCache::DisassembleAndLogHostCode(const void* start, u32 size)
else
hex.append(" ");
}
Log::FastWrite("HostCode", "", LOGLEVEL_DEBUG, " {:016X} {} {}",
Log::FastWrite("HostCode", "", Log::Level::Debug, " {:016X} {} {}",
static_cast<u64>(reinterpret_cast<uintptr_t>(ptr)), hex, buffer);
}

View File

@ -8,7 +8,7 @@
#include <cinttypes>
Log_SetChannel(CPU::Recompiler);
LOG_CHANNEL(CPU::Recompiler);
namespace CPU::Recompiler {

View File

@ -26,7 +26,7 @@
#include <memory>
#include <vector>
Log_SetChannel(DMA);
LOG_CHANNEL(DMA);
namespace DMA {
namespace {

View File

@ -42,7 +42,7 @@
#include <utility>
#include <vector>
Log_SetChannel(FullscreenUI);
LOG_CHANNEL(FullscreenUI);
#define TR_CONTEXT "FullscreenUI"
@ -5128,7 +5128,7 @@ void FullscreenUI::DrawAdvancedSettingsPage()
DrawEnumSetting(bsi, FSUI_CSTR("Log Level"),
FSUI_CSTR("Sets the verbosity of messages logged. Higher levels will log more messages."), "Logging",
"LogLevel", Settings::DEFAULT_LOG_LEVEL, &Settings::ParseLogLevelName, &Settings::GetLogLevelName,
&Settings::GetLogLevelDisplayName, LOGLEVEL_COUNT);
&Settings::GetLogLevelDisplayName, Log::Level::Count);
DrawToggleSetting(bsi, FSUI_CSTR("Log To System Console"), FSUI_CSTR("Logs messages to the console window."),
FSUI_CSTR("Logging"), "LogToConsole", false);
DrawToggleSetting(bsi, FSUI_CSTR("Log To Debug Console"),

View File

@ -31,7 +31,7 @@
#include "IconsFontAwesome5.h"
#include "fmt/format.h"
Log_SetChannel(GameDatabase);
LOG_CHANNEL(GameDatabase);
#include "common/ryml_helpers.h"

View File

@ -35,7 +35,7 @@
#include <unordered_map>
#include <utility>
Log_SetChannel(GameList);
LOG_CHANNEL(GameList);
#ifdef _WIN32
#include "common/windows_headers.h"

View File

@ -21,7 +21,7 @@
#include <sstream>
#include <string>
Log_SetChannel(GDBProtocol);
LOG_CHANNEL(GDBProtocol);
namespace GDBProtocol {
static bool IsPacketInterrupt(std::string_view data);

View File

@ -35,7 +35,7 @@
#include <numbers>
#include <thread>
Log_SetChannel(GPU);
LOG_CHANNEL(GPU);
std::unique_ptr<GPU> g_gpu;
alignas(HOST_PAGE_SIZE) u16 g_vram[VRAM_SIZE / sizeof(u16)];

View File

@ -10,7 +10,7 @@
#include "common/log.h"
#include "common/timer.h"
Log_SetChannel(GPUBackend);
LOG_CHANNEL(GPUBackend);
std::unique_ptr<GPUBackend> g_gpu_backend;

View File

@ -10,7 +10,7 @@
#include "common/log.h"
#include "common/string_util.h"
Log_SetChannel(GPU);
LOG_CHANNEL(GPU);
#define CHECK_COMMAND_SIZE(num_words) \
if (m_fifo.GetSize() < num_words) \

View File

@ -32,7 +32,7 @@
#include <sstream>
#include <tuple>
Log_SetChannel(GPU_HW);
LOG_CHANNEL(GPU_HW);
// TODO: instead of full state restore, only restore what changed

View File

@ -14,7 +14,7 @@
#include <algorithm>
Log_SetChannel(GPU_SW);
LOG_CHANNEL(GPU_SW);
GPU_SW::GPU_SW() = default;

View File

@ -9,7 +9,7 @@
#include "common/log.h"
#include "common/string_util.h"
Log_SetChannel(GPU_SW_Rasterizer);
LOG_CHANNEL(GPU_SW_Rasterizer);
namespace GPU_SW_Rasterizer {
// Default implementation, compatible with all ISAs.

View File

@ -20,7 +20,7 @@
#ifdef _DEBUG
#include "common/log.h"
Log_SetChannel(GunCon);
LOG_CHANNEL(GunCon);
#endif
static constexpr std::array<u8, static_cast<size_t>(GunCon::Binding::ButtonCount)> s_button_indices = {{13, 3, 14}};

View File

@ -27,7 +27,7 @@
#include <cstdarg>
#include <limits>
Log_SetChannel(Host);
LOG_CHANNEL(Host);
namespace Host {
static std::mutex s_settings_mutex;

View File

@ -6,7 +6,7 @@
#include "common/log.h"
Log_SetChannel(HostInterfaceProgressCallback);
LOG_CHANNEL(HostInterfaceProgressCallback);
HostInterfaceProgressCallback::HostInterfaceProgressCallback() : ProgressCallback()
{

View File

@ -44,7 +44,7 @@
#include <mutex>
#include <span>
Log_SetChannel(ImGuiManager);
LOG_CHANNEL(ImGuiManager);
namespace ImGuiManager {
static void FormatProcessorStat(SmallStringBase& text, double usage, double time);

View File

@ -8,7 +8,7 @@
#include "common/log.h"
Log_SetChannel(InterruptController);
LOG_CHANNEL(InterruptController);
namespace InterruptController {

View File

@ -19,7 +19,7 @@
#include "IconsPromptFont.h"
#include <array>
Log_SetChannel(Justifier);
LOG_CHANNEL(Justifier);
// #define CHECK_TIMING 1
#ifdef CHECK_TIMING

View File

@ -20,7 +20,7 @@
#include <array>
#include <memory>
Log_SetChannel(MDEC);
LOG_CHANNEL(MDEC);
namespace MDEC {
namespace {

View File

@ -18,7 +18,7 @@
#include "IconsFontAwesome5.h"
#include "fmt/format.h"
Log_SetChannel(MemoryCard);
LOG_CHANNEL(MemoryCard);
MemoryCard::MemoryCard()
: m_save_event(

View File

@ -19,7 +19,7 @@
#include <cstdio>
#include <optional>
Log_SetChannel(MemoryCard);
LOG_CHANNEL(MemoryCard);
namespace MemoryCardImage {
namespace {

View File

@ -11,7 +11,7 @@
#include "common/log.h"
#include "common/types.h"
Log_SetChannel(Multitap);
LOG_CHANNEL(Multitap);
Multitap::Multitap()
{

View File

@ -23,7 +23,7 @@
#include <cmath>
Log_SetChannel(NeGconRumble);
LOG_CHANNEL(NeGconRumble);
// Mapping of Button to index of corresponding bit in m_button_state
static constexpr std::array<u8, static_cast<size_t>(NeGconRumble::Button::Count)> s_button_indices = {3, 4, 5, 6,

View File

@ -26,7 +26,7 @@
#include <array>
#include <memory>
Log_SetChannel(Pad);
LOG_CHANNEL(Pad);
namespace Pad {

View File

@ -10,7 +10,7 @@
#include "common/path.h"
#include "common/string_util.h"
Log_SetChannel(PCDrv);
LOG_CHANNEL(PCDrv);
static constexpr u32 MAX_FILES = 100;

View File

@ -16,7 +16,7 @@
#include <array>
#include <cmath>
Log_SetChannel(PlayStationMouse);
LOG_CHANNEL(PlayStationMouse);
static constexpr std::array<u8, static_cast<size_t>(PlayStationMouse::Binding::ButtonCount)> s_button_indices = {
{11, 10}};

View File

@ -15,7 +15,7 @@
#include <cstring>
Log_SetChannel(PSFLoader);
LOG_CHANNEL(PSFLoader);
namespace PSFLoader {
static bool LoadLibraryPSF(const std::string& path, bool use_pc_sp, Error* error, u32 depth = 0);

View File

@ -25,7 +25,7 @@
#include <cctype>
#include <numeric>
Log_SetChannel(Settings);
LOG_CHANNEL(Settings);
Settings g_settings;
@ -906,13 +906,13 @@ static constexpr const std::array s_log_level_display_names = {
TRANSLATE_DISAMBIG_NOOP("Settings", "Trace", "LogLevel"),
};
std::optional<LOGLEVEL> Settings::ParseLogLevelName(const char* str)
std::optional<Log::Level> Settings::ParseLogLevelName(const char* str)
{
int index = 0;
for (const char* name : s_log_level_names)
{
if (StringUtil::Strcasecmp(name, str) == 0)
return static_cast<LOGLEVEL>(index);
return static_cast<Log::Level>(index);
index++;
}
@ -920,12 +920,12 @@ std::optional<LOGLEVEL> Settings::ParseLogLevelName(const char* str)
return std::nullopt;
}
const char* Settings::GetLogLevelName(LOGLEVEL level)
const char* Settings::GetLogLevelName(Log::Level level)
{
return s_log_level_names[static_cast<size_t>(level)];
}
const char* Settings::GetLogLevelDisplayName(LOGLEVEL level)
const char* Settings::GetLogLevelDisplayName(Log::Level level)
{
return Host::TranslateToCString("Settings", s_log_level_display_names[static_cast<size_t>(level)], "LogLevel");
}

View File

@ -270,7 +270,7 @@ struct Settings
std::string pcdrv_root;
bool pcdrv_enable_writes = false;
LOGLEVEL log_level = DEFAULT_LOG_LEVEL;
Log::Level log_level = DEFAULT_LOG_LEVEL;
std::string log_filter;
bool log_timestamps : 1 = true;
bool log_to_console : 1 = false;
@ -361,9 +361,9 @@ struct Settings
static void SetDefaultControllerConfig(SettingsInterface& si);
static void SetDefaultHotkeyConfig(SettingsInterface& si);
static std::optional<LOGLEVEL> ParseLogLevelName(const char* str);
static const char* GetLogLevelName(LOGLEVEL level);
static const char* GetLogLevelDisplayName(LOGLEVEL level);
static std::optional<Log::Level> ParseLogLevelName(const char* str);
static const char* GetLogLevelName(Log::Level level);
static const char* GetLogLevelDisplayName(Log::Level level);
static std::span<const char*> GetLogFilters();
static std::optional<ConsoleRegion> ParseConsoleRegionName(const char* str);
@ -512,7 +512,7 @@ struct Settings
static constexpr s32 DEFAULT_ACHIEVEMENT_NOTIFICATION_TIME = 5;
static constexpr s32 DEFAULT_LEADERBOARD_NOTIFICATION_TIME = 10;
static constexpr LOGLEVEL DEFAULT_LOG_LEVEL = LOGLEVEL_INFO;
static constexpr Log::Level DEFAULT_LOG_LEVEL = Log::Level::Info;
static constexpr SaveStateCompressionMode DEFAULT_SAVE_STATE_COMPRESSION_MODE = SaveStateCompressionMode::ZstDefault;

View File

@ -13,7 +13,7 @@
#include <array>
#include <memory>
Log_SetChannel(SIO);
LOG_CHANNEL(SIO);
namespace SIO {
namespace {

View File

@ -27,7 +27,7 @@
#include <memory>
Log_SetChannel(SPU);
LOG_CHANNEL(SPU);
// Enable to dump all voices of the SPU audio individually.
// #define SPU_DUMP_ALL_VOICES 1

View File

@ -80,7 +80,7 @@
#include <zstd.h>
#include <zstd_errors.h>
Log_SetChannel(System);
LOG_CHANNEL(System);
#ifdef _WIN32
#include "common/windows_headers.h"

View File

@ -25,7 +25,7 @@
#include <unordered_map>
#include <vector>
Log_SetChannel(TextureReplacements);
LOG_CHANNEL(TextureReplacements);
namespace TextureReplacements {
namespace {

View File

@ -17,7 +17,7 @@
#include <array>
#include <memory>
Log_SetChannel(Timers);
LOG_CHANNEL(Timers);
namespace Timers {
namespace {

View File

@ -12,7 +12,7 @@
#include "common/log.h"
#include "common/thirdparty/SmallVector.h"
Log_SetChannel(TimingEvents);
LOG_CHANNEL(TimingEvents);
namespace TimingEvents {

View File

@ -162,8 +162,8 @@ AdvancedSettingsWidget::AdvancedSettingsWidget(SettingsWindow* dialog, QWidget*
m_ui.setupUi(this);
for (u32 i = 0; i < static_cast<u32>(LOGLEVEL_COUNT); i++)
m_ui.logLevel->addItem(QString::fromUtf8(Settings::GetLogLevelDisplayName(static_cast<LOGLEVEL>(i))));
for (u32 i = 0; i < static_cast<u32>(Log::Level::Count); i++)
m_ui.logLevel->addItem(QString::fromUtf8(Settings::GetLogLevelDisplayName(static_cast<Log::Level>(i))));
SettingWidgetBinder::BindWidgetToEnumSetting(sif, m_ui.logLevel, "Logging", "LogLevel", &Settings::ParseLogLevelName,
&Settings::GetLogLevelName, Settings::DEFAULT_LOG_LEVEL);
@ -298,13 +298,13 @@ void AdvancedSettingsWidget::onResetToDefaultClicked()
setChoiceTweakOption(m_ui.tweakOptionTable, i++,
Settings::DEFAULT_CPU_FASTMEM_MODE); // Recompiler fastmem mode
setChoiceTweakOption(m_ui.tweakOptionTable, i++,
Settings::DEFAULT_CDROM_MECHACON_VERSION); // CDROM Mechacon Version
setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // CDROM Region Check
setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Allow booting without SBI file
setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Export Shared Memory
setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Enable PCDRV
setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Enable PCDRV Writes
setDirectoryOption(m_ui.tweakOptionTable, i++, ""); // PCDrv Root Directory
Settings::DEFAULT_CDROM_MECHACON_VERSION); // CDROM Mechacon Version
setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // CDROM Region Check
setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Allow booting without SBI file
setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Export Shared Memory
setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Enable PCDRV
setBooleanTweakOption(m_ui.tweakOptionTable, i++, false); // Enable PCDRV Writes
setDirectoryOption(m_ui.tweakOptionTable, i++, ""); // PCDrv Root Directory
return;
}

View File

@ -66,7 +66,7 @@ static const char* THIS_RELEASE_TAG = SCM_RELEASE_TAG;
#endif
Log_SetChannel(AutoUpdaterDialog);
LOG_CHANNEL(AutoUpdaterDialog);
AutoUpdaterDialog::AutoUpdaterDialog(QWidget* parent /* = nullptr */) : QDialog(parent)
{

View File

@ -38,7 +38,7 @@
#include <QtWidgets/QSpinBox>
#include <algorithm>
Log_SetChannel(ControllerBindingWidget);
LOG_CHANNEL(ControllerBindingWidget);
ControllerBindingWidget::ControllerBindingWidget(QWidget* parent, ControllerSettingsWindow* dialog, u32 port)
: QWidget(parent), m_dialog(dialog), m_config_section(Controller::GetSettingsSection(port)), m_port_number(port)

View File

@ -30,7 +30,7 @@
#include "common/windows_headers.h"
#endif
Log_SetChannel(DisplayWidget);
LOG_CHANNEL(DisplayWidget);
DisplayWidget::DisplayWidget(QWidget* parent) : QWidget(parent)
{

View File

@ -157,11 +157,11 @@ void LogWindow::createUi()
settings_menu->addSeparator();
m_level_menu = settings_menu->addMenu(tr("&Log Level"));
for (u32 i = 0; i < static_cast<u32>(LOGLEVEL_COUNT); i++)
for (u32 i = 0; i < static_cast<u32>(Log::Level::Count); i++)
{
action = m_level_menu->addAction(QString::fromUtf8(Settings::GetLogLevelDisplayName(static_cast<LOGLEVEL>(i))));
action = m_level_menu->addAction(QString::fromUtf8(Settings::GetLogLevelDisplayName(static_cast<Log::Level>(i))));
action->setCheckable(true);
connect(action, &QAction::triggered, this, [this, i]() { setLogLevel(static_cast<LOGLEVEL>(i)); });
connect(action, &QAction::triggered, this, [this, i]() { setLogLevel(static_cast<Log::Level>(i)); });
}
updateLogLevelUi();
@ -191,15 +191,16 @@ void LogWindow::createUi()
void LogWindow::updateLogLevelUi()
{
const u32 level = Settings::ParseLogLevelName(Host::GetBaseStringSettingValue("Logging", "LogLevel", "").c_str())
.value_or(Settings::DEFAULT_LOG_LEVEL);
const Log::Level level =
Settings::ParseLogLevelName(Host::GetBaseStringSettingValue("Logging", "LogLevel", "").c_str())
.value_or(Settings::DEFAULT_LOG_LEVEL);
const QList<QAction*> actions = m_level_menu->actions();
for (u32 i = 0; i < actions.size(); i++)
actions[i]->setChecked(i == level);
actions[i]->setChecked(static_cast<Log::Level>(i) == level);
}
void LogWindow::setLogLevel(LOGLEVEL level)
void LogWindow::setLogLevel(Log::Level level)
{
Host::SetBaseStringSettingValue("Logging", "LogLevel", Settings::GetLogLevelName(level));
Host::CommitBaseSettingChanges();
@ -273,10 +274,11 @@ void LogWindow::onSaveTriggered()
file.write(m_text->toPlainText().toUtf8());
file.close();
appendMessage(QLatin1StringView("LogWindow"), LOGLEVEL_INFO, tr("Log was written to %1.\n").arg(path));
appendMessage(QLatin1StringView("LogWindow"), static_cast<u32>(Log::Level::Info),
tr("Log was written to %1.\n").arg(path));
}
void LogWindow::logCallback(void* pUserParam, const char* channelName, const char* functionName, LOGLEVEL level,
void LogWindow::logCallback(void* pUserParam, const char* channelName, const char* functionName, Log::Level level,
std::string_view message)
{
LogWindow* this_ptr = static_cast<LogWindow*>(pUserParam);
@ -289,11 +291,11 @@ void LogWindow::logCallback(void* pUserParam, const char* channelName, const cha
qmessage.append(QUtf8StringView(message.data(), message.length()));
qmessage.append(QChar('\n'));
const QLatin1StringView qchannel((level <= LOGLEVEL_WARNING) ? functionName : channelName);
const QLatin1StringView qchannel((level <= Log::Level::Warning) ? functionName : channelName);
if (g_emu_thread->isOnUIThread())
{
this_ptr->appendMessage(qchannel, level, qmessage);
this_ptr->appendMessage(qchannel, static_cast<u32>(level), qmessage);
}
else
{
@ -328,8 +330,9 @@ void LogWindow::appendMessage(const QLatin1StringView& channel, quint32 level, c
temp_cursor.movePosition(QTextCursor::End);
{
static constexpr const QChar level_characters[LOGLEVEL_COUNT] = {'X', 'E', 'W', 'I', 'V', 'D', 'B', 'T'};
static constexpr const QColor level_colors[LOGLEVEL_COUNT] = {
static constexpr const QChar level_characters[static_cast<size_t>(Log::Level::Count)] = {'X', 'E', 'W', 'I',
'V', 'D', 'B', 'T'};
static constexpr const QColor level_colors[static_cast<size_t>(Log::Level::Count)] = {
QColor(255, 255, 255), // NONE
QColor(0xE7, 0x48, 0x56), // ERROR, Red Intensity
QColor(0xF9, 0xF1, 0xA5), // WARNING, Yellow Intensity
@ -353,7 +356,7 @@ void LogWindow::appendMessage(const QLatin1StringView& channel, quint32 level, c
temp_cursor.insertText(qtimestamp);
}
const QString qchannel = (level <= LOGLEVEL_WARNING) ?
const QString qchannel = (level <= static_cast<u32>(Log::Level::Warning)) ?
QStringLiteral("%1(%2): ").arg(level_characters[level]).arg(channel) :
QStringLiteral("%1/%2: ").arg(level_characters[level]).arg(channel);
format.setForeground(QBrush(channel_color));

View File

@ -28,11 +28,11 @@ public:
private:
void createUi();
void updateLogLevelUi();
void setLogLevel(LOGLEVEL level);
void setLogLevel(Log::Level level);
void populateFilters(QMenu* filter_menu);
void setChannelFiltered(size_t index, bool state);
static void logCallback(void* pUserParam, const char* channelName, const char* functionName, LOGLEVEL level,
static void logCallback(void* pUserParam, const char* channelName, const char* functionName, Log::Level level,
std::string_view message);
protected:

View File

@ -58,7 +58,7 @@
#include <VersionHelpers.h>
#endif
Log_SetChannel(MainWindow);
LOG_CHANNEL(MainWindow);
static constexpr char DISC_IMAGE_FILTER[] = QT_TRANSLATE_NOOP(
"MainWindow",

View File

@ -66,7 +66,7 @@
#include <cstdlib>
#include <memory>
Log_SetChannel(QtHost);
LOG_CHANNEL(QtHost);
#ifdef _WIN32
#include "common/windows_headers.h"

View File

@ -32,7 +32,7 @@
#include <ShlObj.h>
#endif
Log_SetChannel(QTTranslations);
LOG_CHANNEL(QTTranslations);
#if 0
// Qt internal strings we'd like to have translated

View File

@ -39,7 +39,7 @@
#include "common/windows_headers.h"
#endif
Log_SetChannel(QtUtils);
LOG_CHANNEL(QtUtils);
QFrame* QtUtils::CreateHorizontalLine(QWidget* parent)
{

View File

@ -34,7 +34,7 @@
#include <QtWidgets/QScrollBar>
#include <QtWidgets/QTextEdit>
Log_SetChannel(SettingsWindow);
LOG_CHANNEL(SettingsWindow);
static QList<SettingsWindow*> s_open_game_properties_dialogs;

View File

@ -33,7 +33,7 @@
#include <csignal>
#include <cstdio>
Log_SetChannel(RegTestHost);
LOG_CHANNEL(RegTestHost);
namespace RegTestHost {
static bool ParseCommandLineParameters(int argc, char* argv[], std::optional<SystemBootParameters>& autoboot);
@ -109,7 +109,7 @@ bool RegTestHost::InitializeConfig()
si.SetStringValue("Audio", "Backend", AudioStream::GetBackendName(AudioBackend::Null));
si.SetBoolValue("Logging", "LogToConsole", false);
si.SetBoolValue("Logging", "LogToFile", false);
si.SetStringValue("Logging", "LogLevel", Settings::GetLogLevelName(LOGLEVEL_INFO));
si.SetStringValue("Logging", "LogLevel", Settings::GetLogLevelName(Log::Level::Info));
si.SetBoolValue("Main", "ApplyGameSettings", false); // don't want game settings interfering
si.SetBoolValue("BIOS", "PatchFastBoot", true); // no point validating the bios intro..
si.SetFloatValue("Main", "EmulationSpeed", 0.0f);
@ -585,7 +585,7 @@ bool RegTestHost::ParseCommandLineParameters(int argc, char* argv[], std::option
}
else if (CHECK_ARG_PARAM("-log"))
{
std::optional<LOGLEVEL> level = Settings::ParseLogLevelName(argv[++i]);
std::optional<Log::Level> level = Settings::ParseLogLevelName(argv[++i]);
if (!level.has_value())
{
ERROR_LOG("Invalid log level specified.");
@ -715,7 +715,7 @@ bool RegTestHost::SetNewDataRoot(const std::string& filename)
EmuFolders::DataRoot = std::move(dump_directory);
s_base_settings_interface->SetBoolValue("Logging", "LogToConsole", false);
s_base_settings_interface->SetBoolValue("Logging", "LogToFile", true);
s_base_settings_interface->SetStringValue("Logging", "LogLevel", Settings::GetLogLevelName(LOGLEVEL_DEV));
s_base_settings_interface->SetStringValue("Logging", "LogLevel", Settings::GetLogLevelName(Log::Level::Dev));
System::ApplySettings(false);
}

View File

@ -6,7 +6,7 @@
#include "common/cocoa_tools.h"
#include "common/log.h"
Log_SetChannel(CocoaProgressCallback);
LOG_CHANNEL(CocoaProgressCallback);
CocoaProgressCallback::CocoaProgressCallback() : ProgressCallback()
{

View File

@ -8,7 +8,7 @@
#include <CommCtrl.h>
Log_SetChannel(Win32ProgressCallback);
LOG_CHANNEL(Win32ProgressCallback);
Win32ProgressCallback::Win32ProgressCallback() : ProgressCallback()
{

View File

@ -20,7 +20,7 @@
#include <cstring>
#include <limits>
Log_SetChannel(AudioStream);
LOG_CHANNEL(AudioStream);
static constexpr bool LOG_TIMESTRETCH_STATS = false;

View File

@ -13,7 +13,7 @@
#include <array>
Log_SetChannel(CDImage);
LOG_CHANNEL(CDImage);
CDImage::CDImage() = default;

View File

@ -27,7 +27,7 @@
#include <mutex>
#include <optional>
Log_SetChannel(CDImageCHD);
LOG_CHANNEL(CDImageCHD);
namespace {

View File

@ -17,7 +17,7 @@
#include <cinttypes>
#include <map>
Log_SetChannel(CDImageCueSheet);
LOG_CHANNEL(CDImageCueSheet);
namespace {

View File

@ -23,7 +23,7 @@
#include <optional>
#include <span>
Log_SetChannel(CDImageDevice);
LOG_CHANNEL(CDImageDevice);
// Common code
[[maybe_unused]] static constexpr u32 MAX_TRACK_NUMBER = 99;

View File

@ -15,7 +15,7 @@
#include <array>
#include <map>
Log_SetChannel(CDImageEcm);
LOG_CHANNEL(CDImageEcm);
namespace {

View File

@ -15,7 +15,7 @@
#include <map>
#include <sstream>
Log_SetChannel(CDImageMemory);
LOG_CHANNEL(CDImageMemory);
namespace {

View File

@ -14,7 +14,7 @@
#include <cerrno>
#include <map>
Log_SetChannel(CDImageMds);
LOG_CHANNEL(CDImageMds);
namespace {

View File

@ -12,7 +12,7 @@
#include <algorithm>
#include <cerrno>
Log_SetChannel(CDImageMemory);
LOG_CHANNEL(CDImageMemory);
namespace {

View File

@ -22,7 +22,7 @@
#include <variant>
#include <vector>
Log_SetChannel(CDImagePBP);
LOG_CHANNEL(CDImagePBP);
namespace {

View File

@ -14,7 +14,7 @@
#include <map>
#include <unordered_map>
Log_SetChannel(CDImagePPF);
LOG_CHANNEL(CDImagePPF);
namespace {

View File

@ -7,7 +7,7 @@
#include "common/path.h"
#include <algorithm>
#include <memory>
Log_SetChannel(CDSubChannelReplacement);
LOG_CHANNEL(CDSubChannelReplacement);
#pragma pack(push, 1)
struct SBIFileEntry

View File

@ -15,7 +15,7 @@
#include "cubeb/cubeb.h"
#include "fmt/format.h"
Log_SetChannel(CubebAudioStream);
LOG_CHANNEL(CubebAudioStream);
namespace {

View File

@ -9,7 +9,7 @@
#include <cstdarg>
Log_SetChannel(CueParser);
LOG_CHANNEL(CueParser);
namespace CueParser {
static bool TokenMatch(std::string_view s1, const char* token);

View File

@ -22,7 +22,7 @@
#include <d3dcompiler.h>
#include <dxgi1_5.h>
Log_SetChannel(D3D11Device);
LOG_CHANNEL(D3D11Device);
// We need to synchronize instance creation because of adapter enumeration from the UI thread.
static std::mutex s_instance_mutex;

View File

@ -9,7 +9,7 @@
#include "common/error.h"
#include "common/log.h"
Log_SetChannel(D3D11Device);
LOG_CHANNEL(D3D11Device);
D3D11StreamBuffer::D3D11StreamBuffer()
{

View File

@ -13,7 +13,7 @@
#include <array>
Log_SetChannel(D3D11Device);
LOG_CHANNEL(D3D11Device);
std::unique_ptr<GPUTexture> D3D11Device::CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples,
GPUTexture::Type type, GPUTexture::Format format,

View File

@ -27,7 +27,7 @@
#include <limits>
#include <mutex>
Log_SetChannel(D3D12Device);
LOG_CHANNEL(D3D12Device);
// Tweakables
enum : u32

View File

@ -14,7 +14,7 @@
#include <d3dcompiler.h>
Log_SetChannel(D3D12Device);
LOG_CHANNEL(D3D12Device);
D3D12Shader::D3D12Shader(GPUShaderStage stage, Bytecode bytecode) : GPUShader(stage), m_bytecode(std::move(bytecode))
{

View File

@ -13,7 +13,7 @@
#include <algorithm>
Log_SetChannel(D3D12StreamBuffer);
LOG_CHANNEL(D3D12StreamBuffer);
D3D12StreamBuffer::D3D12StreamBuffer() = default;

View File

@ -15,7 +15,7 @@
#include "D3D12MemAlloc.h"
Log_SetChannel(D3D12Device);
LOG_CHANNEL(D3D12Device);
D3D12Texture::D3D12Texture(u32 width, u32 height, u32 layers, u32 levels, u32 samples, Type type, Format format,
DXGI_FORMAT dxgi_format, ComPtr<ID3D12Resource> resource,

View File

@ -19,7 +19,7 @@
#include <dxcapi.h>
#include <dxgi1_5.h>
Log_SetChannel(D3DCommon);
LOG_CHANNEL(D3DCommon);
namespace D3DCommon {
namespace {

View File

@ -15,7 +15,7 @@
#include <cmath>
#include <limits>
Log_SetChannel(DInputSource);
LOG_CHANNEL(DInputSource);
using PFNDIRECTINPUT8CREATE = HRESULT(WINAPI*)(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID* ppvOut,
LPUNKNOWN punkOuter);

Some files were not shown because too many files have changed in this diff Show More