Log: Switch to enum class

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
146 changed files with 291 additions and 291 deletions
+1 -1
View File
@@ -20,7 +20,7 @@
#include <cstring>
#include <limits>
Log_SetChannel(AudioStream);
LOG_CHANNEL(AudioStream);
static constexpr bool LOG_TIMESTRETCH_STATS = false;
+1 -1
View File
@@ -13,7 +13,7 @@
#include <array>
Log_SetChannel(CDImage);
LOG_CHANNEL(CDImage);
CDImage::CDImage() = default;
+1 -1
View File
@@ -27,7 +27,7 @@
#include <mutex>
#include <optional>
Log_SetChannel(CDImageCHD);
LOG_CHANNEL(CDImageCHD);
namespace {
+1 -1
View File
@@ -17,7 +17,7 @@
#include <cinttypes>
#include <map>
Log_SetChannel(CDImageCueSheet);
LOG_CHANNEL(CDImageCueSheet);
namespace {
+1 -1
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;
+1 -1
View File
@@ -15,7 +15,7 @@
#include <array>
#include <map>
Log_SetChannel(CDImageEcm);
LOG_CHANNEL(CDImageEcm);
namespace {
+1 -1
View File
@@ -15,7 +15,7 @@
#include <map>
#include <sstream>
Log_SetChannel(CDImageMemory);
LOG_CHANNEL(CDImageMemory);
namespace {
+1 -1
View File
@@ -14,7 +14,7 @@
#include <cerrno>
#include <map>
Log_SetChannel(CDImageMds);
LOG_CHANNEL(CDImageMds);
namespace {
+1 -1
View File
@@ -12,7 +12,7 @@
#include <algorithm>
#include <cerrno>
Log_SetChannel(CDImageMemory);
LOG_CHANNEL(CDImageMemory);
namespace {
+1 -1
View File
@@ -22,7 +22,7 @@
#include <variant>
#include <vector>
Log_SetChannel(CDImagePBP);
LOG_CHANNEL(CDImagePBP);
namespace {
+1 -1
View File
@@ -14,7 +14,7 @@
#include <map>
#include <unordered_map>
Log_SetChannel(CDImagePPF);
LOG_CHANNEL(CDImagePPF);
namespace {
+1 -1
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
+1 -1
View File
@@ -15,7 +15,7 @@
#include "cubeb/cubeb.h"
#include "fmt/format.h"
Log_SetChannel(CubebAudioStream);
LOG_CHANNEL(CubebAudioStream);
namespace {
+1 -1
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);
+1 -1
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;
+1 -1
View File
@@ -9,7 +9,7 @@
#include "common/error.h"
#include "common/log.h"
Log_SetChannel(D3D11Device);
LOG_CHANNEL(D3D11Device);
D3D11StreamBuffer::D3D11StreamBuffer()
{
+1 -1
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,
+1 -1
View File
@@ -27,7 +27,7 @@
#include <limits>
#include <mutex>
Log_SetChannel(D3D12Device);
LOG_CHANNEL(D3D12Device);
// Tweakables
enum : u32
+1 -1
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))
{
+1 -1
View File
@@ -13,7 +13,7 @@
#include <algorithm>
Log_SetChannel(D3D12StreamBuffer);
LOG_CHANNEL(D3D12StreamBuffer);
D3D12StreamBuffer::D3D12StreamBuffer() = default;
+1 -1
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,
+1 -1
View File
@@ -19,7 +19,7 @@
#include <dxcapi.h>
#include <dxgi1_5.h>
Log_SetChannel(D3DCommon);
LOG_CHANNEL(D3DCommon);
namespace D3DCommon {
namespace {
+1 -1
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);
+1 -1
View File
@@ -25,7 +25,7 @@
#include "spirv_cross/spirv_cross_c.h"
#include "xxhash.h"
Log_SetChannel(GPUDevice);
LOG_CHANNEL(GPUDevice);
#ifdef _WIN32
#include "common/windows_headers.h"
+1 -1
View File
@@ -15,7 +15,7 @@
#include "compress_helpers.h"
Log_SetChannel(GPUShaderCache);
LOG_CHANNEL(GPUShaderCache);
#pragma pack(push, 1)
struct CacheFileHeader
+1 -1
View File
@@ -10,7 +10,7 @@
#include "common/log.h"
#include "common/string_util.h"
Log_SetChannel(GPUTexture);
LOG_CHANNEL(GPUTexture);
GPUTexture::GPUTexture(u16 width, u16 height, u8 layers, u8 levels, u8 samples, Type type, Format format)
: m_width(width), m_height(height), m_layers(layers), m_levels(levels), m_samples(samples), m_type(type),
+1 -1
View File
@@ -11,7 +11,7 @@
#include <cstdarg>
#include <shared_mutex>
Log_SetChannel(Host);
LOG_CHANNEL(Host);
namespace Host {
static std::pair<const char*, u32> LookupTranslationString(std::string_view context, std::string_view msg,
+1 -1
View File
@@ -9,7 +9,7 @@
#include "common/string_util.h"
#include "common/timer.h"
Log_SetChannel(HTTPDownloader);
LOG_CHANNEL(HTTPDownloader);
static constexpr float DEFAULT_TIMEOUT_IN_SECONDS = 30;
static constexpr u32 DEFAULT_MAX_ACTIVE_REQUESTS = 4;
+1 -1
View File
@@ -13,7 +13,7 @@
#include <pthread.h>
#include <signal.h>
Log_SetChannel(HTTPDownloader);
LOG_CHANNEL(HTTPDownloader);
HTTPDownloaderCurl::HTTPDownloaderCurl() : HTTPDownloader()
{
+1 -1
View File
@@ -10,7 +10,7 @@
#include <algorithm>
Log_SetChannel(HTTPDownloader);
LOG_CHANNEL(HTTPDownloader);
HTTPDownloaderWinHttp::HTTPDownloaderWinHttp() : HTTPDownloader()
{
+1 -1
View File
@@ -23,7 +23,7 @@
#endif
// clang-format on
Log_SetChannel(Image);
LOG_CHANNEL(Image);
static bool PNGBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size);
static bool PNGBufferSaver(const RGBA8Image& image, std::vector<u8>* buffer, u8 quality);
+1 -1
View File
@@ -35,7 +35,7 @@
#include <utility>
#include <variant>
Log_SetChannel(ImGuiFullscreen);
LOG_CHANNEL(ImGuiFullscreen);
namespace ImGuiFullscreen {
using MessageDialogCallbackVariant = std::variant<InfoMessageDialogCallback, ConfirmMessageDialogCallback>;
+1 -1
View File
@@ -31,7 +31,7 @@
#include <type_traits>
#include <unordered_map>
Log_SetChannel(ImGuiManager);
LOG_CHANNEL(ImGuiManager);
namespace ImGuiManager {
namespace {
+1 -1
View File
@@ -13,7 +13,7 @@
#include <iterator>
#include <mutex>
Log_SetChannel(INISettingsInterface);
LOG_CHANNEL(INISettingsInterface);
// To prevent races between saving and loading settings, particularly with game settings,
// we only allow one ini to be parsed at any point in time.
+1 -1
View File
@@ -28,7 +28,7 @@
#include <variant>
#include <vector>
Log_SetChannel(InputManager);
LOG_CHANNEL(InputManager);
namespace {
+1 -1
View File
@@ -12,7 +12,7 @@
#include <cctype>
Log_SetChannel(IsoReader);
LOG_CHANNEL(IsoReader);
IsoReader::IsoReader() = default;
+1 -1
View File
@@ -69,7 +69,7 @@ extern "C" {
#endif
Log_SetChannel(MediaCapture);
LOG_CHANNEL(MediaCapture);
namespace {
+4 -4
View File
@@ -21,7 +21,7 @@
#include <mach/mach_time.h>
#include <pthread.h>
Log_SetChannel(MetalDevice);
LOG_CHANNEL(MetalDevice);
// TODO: Disable hazard tracking and issue barriers explicitly.
@@ -75,9 +75,9 @@ static constexpr std::array<MTLPixelFormat, static_cast<u32>(GPUTexture::Format:
static void LogNSError(NSError* error, std::string_view message)
{
Log::FastWrite("MetalDevice", LOGLEVEL_ERROR, message);
Log::FastWrite("MetalDevice", LOGLEVEL_ERROR, " NSError Code: {}", static_cast<u32>(error.code));
Log::FastWrite("MetalDevice", LOGLEVEL_ERROR, " NSError Description: {}", [error.description UTF8String]);
Log::FastWrite("MetalDevice", Log::Level::Error, message);
Log::FastWrite("MetalDevice", Log::Level::Error, " NSError Code: {}", static_cast<u32>(error.code));
Log::FastWrite("MetalDevice", Log::Level::Error, " NSError Description: {}", [error.description UTF8String]);
}
static GPUTexture::Format GetTextureFormatForMTLFormat(MTLPixelFormat fmt)
+1 -1
View File
@@ -8,7 +8,7 @@
#include "common/assert.h"
#include "common/log.h"
Log_SetChannel(MetalDevice);
LOG_CHANNEL(MetalDevice);
MetalStreamBuffer::MetalStreamBuffer() = default;
+1 -1
View File
@@ -32,7 +32,7 @@
#endif
#endif
Log_SetChannel(OpenGLContext);
LOG_CHANNEL(OpenGLContext);
static bool ShouldPreferESContext()
{
+1 -1
View File
@@ -9,7 +9,7 @@
#include <dlfcn.h>
Log_SetChannel(OpenGLContext);
LOG_CHANNEL(OpenGLContext);
OpenGLContextAGL::OpenGLContextAGL(const WindowInfo& wi) : OpenGLContext(wi)
{
+1 -1
View File
@@ -13,7 +13,7 @@
#include <optional>
#include <vector>
Log_SetChannel(OpenGLContext);
LOG_CHANNEL(OpenGLContext);
static DynamicLibrary s_egl_library;
static std::atomic_uint32_t s_egl_refcount = 0;
+1 -1
View File
@@ -9,7 +9,7 @@
#include "common/log.h"
#include "common/scoped_guard.h"
Log_SetChannel(GL::OpenGLContext);
LOG_CHANNEL(GL::OpenGLContext);
#ifdef __clang__
#pragma clang diagnostic ignored "-Wmicrosoft-cast"
+1 -1
View File
@@ -19,7 +19,7 @@
#include <array>
#include <tuple>
Log_SetChannel(OpenGLDevice);
LOG_CHANNEL(OpenGLDevice);
static constexpr const std::array<GLenum, GPUDevice::MAX_RENDER_TARGETS> s_draw_buffers = {
{GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3}};
+1 -1
View File
@@ -21,7 +21,7 @@
#include <cerrno>
Log_SetChannel(OpenGLDevice);
LOG_CHANNEL(OpenGLDevice);
struct PipelineDiskCacheFooter
{
+1 -1
View File
@@ -15,7 +15,7 @@
#include <limits>
#include <tuple>
Log_SetChannel(OpenGLDevice);
LOG_CHANNEL(OpenGLDevice);
// Looking across a range of GPUs, the optimal copy alignment for Vulkan drivers seems
// to be between 1 (AMD/NV) and 64 (Intel). So, we'll go with 64 here.
+1 -1
View File
@@ -17,7 +17,7 @@
#include "common/log.h"
#include "common/small_string.h"
Log_SetChannel(PlatformMisc);
LOG_CHANNEL(PlatformMisc);
#if __has_feature(objc_arc)
#error ARC should not be enabled.
+1 -1
View File
@@ -16,7 +16,7 @@
#include <spawn.h>
#include <unistd.h>
Log_SetChannel(PlatformMisc);
LOG_CHANNEL(PlatformMisc);
bool PlatformMisc::InitializeSocketSupport(Error* error)
{
+1 -1
View File
@@ -18,7 +18,7 @@
#include <WinSock2.h>
#include <mmsystem.h>
Log_SetChannel(PlatformMisc);
LOG_CHANNEL(PlatformMisc);
static bool s_screensaver_suspended = false;
static bool s_winsock_initialized = false;
+1 -1
View File
@@ -26,7 +26,7 @@
#include "common/timer.h"
#include "fmt/format.h"
Log_SetChannel(PostProcessing);
LOG_CHANNEL(PostProcessing);
// TODO: ProgressCallbacks for shader compiling, it can be a bit slow.
// TODO: buffer width/height is wrong on resize, need to change it somehow.
+1 -1
View File
@@ -11,7 +11,7 @@
#include <cstring>
#include <sstream>
Log_SetChannel(PostProcessing);
LOG_CHANNEL(PostProcessing);
void PostProcessing::Shader::ParseKeyValue(std::string_view line, std::string_view* key, std::string_view* value)
{
+1 -1
View File
@@ -32,7 +32,7 @@
#include <sstream>
#include <tuple>
Log_SetChannel(ReShadeFXShader);
LOG_CHANNEL(ReShadeFXShader);
static constexpr s32 DEFAULT_BUFFER_WIDTH = 3840;
static constexpr s32 DEFAULT_BUFFER_HEIGHT = 2160;
+1 -1
View File
@@ -12,7 +12,7 @@
#include <cstring>
#include <sstream>
Log_SetChannel(PostProcessing);
LOG_CHANNEL(PostProcessing);
namespace {
class PostProcessingGLSLShaderGen : public ShaderGen
+1 -1
View File
@@ -9,7 +9,7 @@
#include <SDL.h>
Log_SetChannel(SDLAudioStream);
LOG_CHANNEL(SDLAudioStream);
namespace {
class SDLAudioStream final : public AudioStream
+10 -11
View File
@@ -23,7 +23,7 @@
#include <dispatch/dispatch.h>
#endif
Log_SetChannel(SDLInputSource);
LOG_CHANNEL(SDLInputSource);
static constexpr const char* CONTROLLER_DB_FILENAME = "gamecontrollerdb.txt";
@@ -139,14 +139,14 @@ static void SetControllerRGBLED(SDL_GameController* gc, u32 color)
static void SDLLogCallback(void* userdata, int category, SDL_LogPriority priority, const char* message)
{
static constexpr LOGLEVEL priority_map[SDL_NUM_LOG_PRIORITIES] = {
LOGLEVEL_DEBUG,
LOGLEVEL_DEBUG, // SDL_LOG_PRIORITY_VERBOSE
LOGLEVEL_DEBUG, // SDL_LOG_PRIORITY_DEBUG
LOGLEVEL_INFO, // SDL_LOG_PRIORITY_INFO
LOGLEVEL_WARNING, // SDL_LOG_PRIORITY_WARN
LOGLEVEL_ERROR, // SDL_LOG_PRIORITY_ERROR
LOGLEVEL_ERROR, // SDL_LOG_PRIORITY_CRITICAL
static constexpr Log::Level priority_map[SDL_NUM_LOG_PRIORITIES] = {
Log::Level::Debug,
Log::Level::Debug, // SDL_LOG_PRIORITY_VERBOSE
Log::Level::Debug, // SDL_LOG_PRIORITY_DEBUG
Log::Level::Info, // SDL_LOG_PRIORITY_INFO
Log::Level::Warning, // SDL_LOG_PRIORITY_WARN
Log::Level::Error, // SDL_LOG_PRIORITY_ERROR
Log::Level::Error, // SDL_LOG_PRIORITY_CRITICAL
};
Log::Write("SDL", "SDL", priority_map[priority], message);
@@ -191,8 +191,7 @@ void SDLInputSource::UpdateSettings(SettingsInterface& si, std::unique_lock<std:
#endif
if (m_controller_enhanced_mode != old_controller_enhanced_mode ||
m_controller_ps5_player_led != old_controller_ps5_player_led ||
drivers_changed)
m_controller_ps5_player_led != old_controller_ps5_player_led || drivers_changed)
{
settings_lock.unlock();
ShutdownSubsystem();
+1 -1
View File
@@ -15,7 +15,7 @@
#include "opengl_loader.h"
#endif
Log_SetChannel(ShaderGen);
LOG_CHANNEL(ShaderGen);
ShaderGen::ShaderGen(RenderAPI render_api, GPUShaderLanguage shader_language, bool supports_dual_source_blend,
bool supports_framebuffer_fetch)
+1 -1
View File
@@ -58,7 +58,7 @@ using nfds_t = ULONG;
#define SD_BOTH SHUT_RDWR
#endif
Log_SetChannel(Sockets);
LOG_CHANNEL(Sockets);
static bool SetNonBlocking(SocketDescriptor sd, Error* error)
{
+1 -1
View File
@@ -6,7 +6,7 @@
#include "common/small_string.h"
#include <cinttypes>
#include <cstring>
Log_SetChannel(StateWrapper);
LOG_CHANNEL(StateWrapper);
StateWrapper::StateWrapper(std::span<u8> data, Mode mode, u32 version)
: m_data(data.data()), m_size(data.size()), m_mode(mode), m_version(version)
+1 -1
View File
@@ -106,7 +106,7 @@ const char* Vulkan::VkResultToString(VkResult res)
void Vulkan::LogVulkanResult(const char* func_name, VkResult res, std::string_view msg)
{
Log::FastWrite("VulkanDevice", func_name, LOGLEVEL_ERROR, "{} (0x{:08X}: {})", msg, static_cast<unsigned>(res),
Log::FastWrite("VulkanDevice", func_name, Log::Level::Error, "{} (0x{:08X}: {})", msg, static_cast<unsigned>(res),
VkResultToString(res));
}
+1 -1
View File
@@ -27,7 +27,7 @@
#include <limits>
#include <mutex>
Log_SetChannel(VulkanDevice);
LOG_CHANNEL(VulkanDevice);
// TODO: VK_KHR_display.
+1 -1
View File
@@ -16,7 +16,7 @@
#include <cstring>
#include <string>
Log_SetChannel(VulkanDevice);
LOG_CHANNEL(VulkanDevice);
extern "C" {
+1 -1
View File
@@ -11,7 +11,7 @@
#include "common/heap_array.h"
#include "common/log.h"
Log_SetChannel(VulkanDevice);
LOG_CHANNEL(VulkanDevice);
VulkanShader::VulkanShader(GPUShaderStage stage, VkShaderModule mod) : GPUShader(stage), m_module(mod)
{
+1 -1
View File
@@ -9,7 +9,7 @@
#include "common/assert.h"
#include "common/bitutils.h"
#include "common/log.h"
Log_SetChannel(VulkanDevice);
LOG_CHANNEL(VulkanDevice);
VulkanStreamBuffer::VulkanStreamBuffer() = default;
+1 -1
View File
@@ -20,7 +20,7 @@
#include "util/metal_layer.h"
#endif
Log_SetChannel(VulkanDevice);
LOG_CHANNEL(VulkanDevice);
static_assert(VulkanSwapChain::NUM_SEMAPHORES == (VulkanDevice::NUM_COMMAND_BUFFERS + 1));
+1 -1
View File
@@ -10,7 +10,7 @@
#include "common/bitutils.h"
#include "common/log.h"
Log_SetChannel(VulkanDevice);
LOG_CHANNEL(VulkanDevice);
static constexpr const VkComponentMapping s_identity_swizzle{
VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
+1 -1
View File
@@ -4,7 +4,7 @@
#include "wav_writer.h"
#include "common/file_system.h"
#include "common/log.h"
Log_SetChannel(WAVWriter);
LOG_CHANNEL(WAVWriter);
namespace {
#pragma pack(push, 1)
+1 -1
View File
@@ -15,7 +15,7 @@
#include <hidusage.h>
#include <malloc.h>
Log_SetChannel(Win32RawInputSource);
LOG_CHANNEL(Win32RawInputSource);
static const wchar_t* WINDOW_CLASS_NAME = L"Win32RawInputSource";
static bool s_window_class_registered = false;
+1 -1
View File
@@ -9,7 +9,7 @@
#include "common/log.h"
#include "common/scoped_guard.h"
Log_SetChannel(WindowInfo);
LOG_CHANNEL(WindowInfo);
void WindowInfo::SetSurfaceless()
{
+1 -1
View File
@@ -13,7 +13,7 @@
#include <cmath>
Log_SetChannel(XInputSource);
LOG_CHANNEL(XInputSource);
static const char* s_axis_names[XInputSource::NUM_AXES] = {
"LeftX", // AXIS_LEFTX