Merge pull request #9187 from lioncash/commonlog

Common: Migrate logging to fmt
This commit is contained in:
Léo Lam 2020-10-26 19:01:26 +01:00 committed by GitHub
commit 07e6d008bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 154 additions and 152 deletions

View File

@ -1092,8 +1092,6 @@ void ARM64XEmitter::QuickCallFunction(ARM64Reg scratchreg, const void* func)
distance >>= 2; // Can only branch to opcode-aligned (4) addresses distance >>= 2; // Can only branch to opcode-aligned (4) addresses
if (!IsInRangeImm26(distance)) if (!IsInRangeImm26(distance))
{ {
// WARN_LOG(DYNA_REC, "Distance too far in function call (%p to %p)! Using scratch.", m_code,
// func);
MOVI2R(scratchreg, (uintptr_t)func); MOVI2R(scratchreg, (uintptr_t)func);
BLR(scratchreg); BLR(scratchreg);
} }

View File

@ -135,14 +135,14 @@ bool IsFile(const std::string& path)
// Doesn't supports deleting a directory // Doesn't supports deleting a directory
bool Delete(const std::string& filename) bool Delete(const std::string& filename)
{ {
INFO_LOG(COMMON, "Delete: file %s", filename.c_str()); INFO_LOG_FMT(COMMON, "Delete: file {}", filename);
#ifdef ANDROID #ifdef ANDROID
if (StringBeginsWith(filename, "content://")) if (StringBeginsWith(filename, "content://"))
{ {
const bool success = DeleteAndroidContent(filename); const bool success = DeleteAndroidContent(filename);
if (!success) if (!success)
WARN_LOG(COMMON, "Delete failed on %s", filename.c_str()); WARN_LOG_FMT(COMMON, "Delete failed on {}", filename);
return success; return success;
} }
#endif #endif
@ -152,29 +152,27 @@ bool Delete(const std::string& filename)
// Return true because we care about the file not being there, not the actual delete. // Return true because we care about the file not being there, not the actual delete.
if (!file_info.Exists()) if (!file_info.Exists())
{ {
WARN_LOG(COMMON, "Delete: %s does not exist", filename.c_str()); WARN_LOG_FMT(COMMON, "Delete: {} does not exist", filename);
return true; return true;
} }
// We can't delete a directory // We can't delete a directory
if (file_info.IsDirectory()) if (file_info.IsDirectory())
{ {
WARN_LOG(COMMON, "Delete failed: %s is a directory", filename.c_str()); WARN_LOG_FMT(COMMON, "Delete failed: {} is a directory", filename);
return false; return false;
} }
#ifdef _WIN32 #ifdef _WIN32
if (!DeleteFile(UTF8ToTStr(filename).c_str())) if (!DeleteFile(UTF8ToTStr(filename).c_str()))
{ {
WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s", filename.c_str(), WARN_LOG_FMT(COMMON, "Delete: DeleteFile failed on {}: {}", filename, GetLastErrorString());
GetLastErrorString().c_str());
return false; return false;
} }
#else #else
if (unlink(filename.c_str()) == -1) if (unlink(filename.c_str()) == -1)
{ {
WARN_LOG(COMMON, "Delete: unlink failed on %s: %s", filename.c_str(), WARN_LOG_FMT(COMMON, "Delete: unlink failed on {}: {}", filename, LastStrerrorString());
LastStrerrorString().c_str());
return false; return false;
} }
#endif #endif
@ -185,31 +183,31 @@ bool Delete(const std::string& filename)
// Returns true if successful, or path already exists. // Returns true if successful, or path already exists.
bool CreateDir(const std::string& path) bool CreateDir(const std::string& path)
{ {
INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str()); INFO_LOG_FMT(COMMON, "CreateDir: directory {}", path);
#ifdef _WIN32 #ifdef _WIN32
if (::CreateDirectory(UTF8ToTStr(path).c_str(), nullptr)) if (::CreateDirectory(UTF8ToTStr(path).c_str(), nullptr))
return true; return true;
DWORD error = GetLastError(); const DWORD error = GetLastError();
if (error == ERROR_ALREADY_EXISTS) if (error == ERROR_ALREADY_EXISTS)
{ {
WARN_LOG(COMMON, "CreateDir: CreateDirectory failed on %s: already exists", path.c_str()); WARN_LOG_FMT(COMMON, "CreateDir: CreateDirectory failed on {}: already exists", path);
return true; return true;
} }
ERROR_LOG(COMMON, "CreateDir: CreateDirectory failed on %s: %i", path.c_str(), error); ERROR_LOG_FMT(COMMON, "CreateDir: CreateDirectory failed on {}: {}", path, error);
return false; return false;
#else #else
if (mkdir(path.c_str(), 0755) == 0) if (mkdir(path.c_str(), 0755) == 0)
return true; return true;
int err = errno; const int err = errno;
if (err == EEXIST) if (err == EEXIST)
{ {
WARN_LOG(COMMON, "CreateDir: mkdir failed on %s: already exists", path.c_str()); WARN_LOG_FMT(COMMON, "CreateDir: mkdir failed on {}: already exists", path);
return true; return true;
} }
ERROR_LOG(COMMON, "CreateDir: mkdir failed on %s: %s", path.c_str(), strerror(err)); ERROR_LOG_FMT(COMMON, "CreateDir: mkdir failed on {}: {}", path, strerror(err));
return false; return false;
#endif #endif
} }
@ -218,11 +216,11 @@ bool CreateDir(const std::string& path)
bool CreateFullPath(const std::string& fullPath) bool CreateFullPath(const std::string& fullPath)
{ {
int panicCounter = 100; int panicCounter = 100;
INFO_LOG(COMMON, "CreateFullPath: path %s", fullPath.c_str()); INFO_LOG_FMT(COMMON, "CreateFullPath: path {}", fullPath);
if (Exists(fullPath)) if (Exists(fullPath))
{ {
INFO_LOG(COMMON, "CreateFullPath: path exists %s", fullPath.c_str()); INFO_LOG_FMT(COMMON, "CreateFullPath: path exists {}", fullPath);
return true; return true;
} }
@ -245,7 +243,7 @@ bool CreateFullPath(const std::string& fullPath)
panicCounter--; panicCounter--;
if (panicCounter <= 0) if (panicCounter <= 0)
{ {
ERROR_LOG(COMMON, "CreateFullPath: directory structure is too deep"); ERROR_LOG_FMT(COMMON, "CreateFullPath: directory structure is too deep");
return false; return false;
} }
position++; position++;
@ -255,25 +253,24 @@ bool CreateFullPath(const std::string& fullPath)
// Deletes a directory filename, returns true on success // Deletes a directory filename, returns true on success
bool DeleteDir(const std::string& filename) bool DeleteDir(const std::string& filename)
{ {
INFO_LOG(COMMON, "DeleteDir: directory %s", filename.c_str()); INFO_LOG_FMT(COMMON, "DeleteDir: directory {}", filename);
// check if a directory // check if a directory
if (!IsDirectory(filename)) if (!IsDirectory(filename))
{ {
ERROR_LOG(COMMON, "DeleteDir: Not a directory %s", filename.c_str()); ERROR_LOG_FMT(COMMON, "DeleteDir: Not a directory {}", filename);
return false; return false;
} }
#ifdef _WIN32 #ifdef _WIN32
if (::RemoveDirectory(UTF8ToTStr(filename).c_str())) if (::RemoveDirectory(UTF8ToTStr(filename).c_str()))
return true; return true;
ERROR_LOG(COMMON, "DeleteDir: RemoveDirectory failed on %s: %s", filename.c_str(), ERROR_LOG_FMT(COMMON, "DeleteDir: RemoveDirectory failed on {}: {}", filename,
GetLastErrorString().c_str()); GetLastErrorString());
#else #else
if (rmdir(filename.c_str()) == 0) if (rmdir(filename.c_str()) == 0)
return true; return true;
ERROR_LOG(COMMON, "DeleteDir: rmdir failed on %s: %s", filename.c_str(), ERROR_LOG_FMT(COMMON, "DeleteDir: rmdir failed on {}: {}", filename, LastStrerrorString());
LastStrerrorString().c_str());
#endif #endif
return false; return false;
@ -282,7 +279,7 @@ bool DeleteDir(const std::string& filename)
// renames file srcFilename to destFilename, returns true on success // renames file srcFilename to destFilename, returns true on success
bool Rename(const std::string& srcFilename, const std::string& destFilename) bool Rename(const std::string& srcFilename, const std::string& destFilename)
{ {
INFO_LOG(COMMON, "Rename: %s --> %s", srcFilename.c_str(), destFilename.c_str()); INFO_LOG_FMT(COMMON, "Rename: {} --> {}", srcFilename, destFilename);
#ifdef _WIN32 #ifdef _WIN32
auto sf = UTF8ToTStr(srcFilename); auto sf = UTF8ToTStr(srcFilename);
auto df = UTF8ToTStr(destFilename); auto df = UTF8ToTStr(destFilename);
@ -297,13 +294,13 @@ bool Rename(const std::string& srcFilename, const std::string& destFilename)
if (MoveFile(sf.c_str(), df.c_str())) if (MoveFile(sf.c_str(), df.c_str()))
return true; return true;
} }
ERROR_LOG(COMMON, "Rename: MoveFile failed on %s --> %s: %s", srcFilename.c_str(), ERROR_LOG_FMT(COMMON, "Rename: MoveFile failed on {} --> {}: {}", srcFilename, destFilename,
destFilename.c_str(), GetLastErrorString().c_str()); GetLastErrorString());
#else #else
if (rename(srcFilename.c_str(), destFilename.c_str()) == 0) if (rename(srcFilename.c_str(), destFilename.c_str()) == 0)
return true; return true;
ERROR_LOG(COMMON, "Rename: rename failed on %s --> %s: %s", srcFilename.c_str(), ERROR_LOG_FMT(COMMON, "Rename: rename failed on {} --> {}: {}", srcFilename, destFilename,
destFilename.c_str(), LastStrerrorString().c_str()); LastStrerrorString());
#endif #endif
return false; return false;
} }
@ -346,13 +343,13 @@ bool RenameSync(const std::string& srcFilename, const std::string& destFilename)
// copies file source_path to destination_path, returns true on success // copies file source_path to destination_path, returns true on success
bool Copy(const std::string& source_path, const std::string& destination_path) bool Copy(const std::string& source_path, const std::string& destination_path)
{ {
INFO_LOG(COMMON, "Copy: %s --> %s", source_path.c_str(), destination_path.c_str()); INFO_LOG_FMT(COMMON, "Copy: {} --> {}", source_path, destination_path);
#ifdef _WIN32 #ifdef _WIN32
if (CopyFile(UTF8ToTStr(source_path).c_str(), UTF8ToTStr(destination_path).c_str(), FALSE)) if (CopyFile(UTF8ToTStr(source_path).c_str(), UTF8ToTStr(destination_path).c_str(), FALSE))
return true; return true;
ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s", source_path.c_str(), destination_path.c_str(), ERROR_LOG_FMT(COMMON, "Copy: failed %s --> %s: %s", source_path, destination_path,
GetLastErrorString().c_str()); GetLastErrorString());
return false; return false;
#else #else
std::ifstream source{source_path, std::ios::binary}; std::ifstream source{source_path, std::ios::binary};
@ -378,17 +375,17 @@ u64 GetSize(const int fd)
u64 GetSize(FILE* f) u64 GetSize(FILE* f)
{ {
// can't use off_t here because it can be 32-bit // can't use off_t here because it can be 32-bit
u64 pos = ftello(f); const u64 pos = ftello(f);
if (fseeko(f, 0, SEEK_END) != 0) if (fseeko(f, 0, SEEK_END) != 0)
{ {
ERROR_LOG(COMMON, "GetSize: seek failed %p: %s", f, LastStrerrorString().c_str()); ERROR_LOG_FMT(COMMON, "GetSize: seek failed {}: {}", fmt::ptr(f), LastStrerrorString());
return 0; return 0;
} }
u64 size = ftello(f); const u64 size = ftello(f);
if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0)) if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0))
{ {
ERROR_LOG(COMMON, "GetSize: seek failed %p: %s", f, LastStrerrorString().c_str()); ERROR_LOG_FMT(COMMON, "GetSize: seek failed {}: {}", fmt::ptr(f), LastStrerrorString());
return 0; return 0;
} }
@ -398,12 +395,11 @@ u64 GetSize(FILE* f)
// creates an empty file filename, returns true on success // creates an empty file filename, returns true on success
bool CreateEmptyFile(const std::string& filename) bool CreateEmptyFile(const std::string& filename)
{ {
INFO_LOG(COMMON, "CreateEmptyFile: %s", filename.c_str()); INFO_LOG_FMT(COMMON, "CreateEmptyFile: {}", filename);
if (!File::IOFile(filename, "wb")) if (!File::IOFile(filename, "wb"))
{ {
ERROR_LOG(COMMON, "CreateEmptyFile: failed %s: %s", filename.c_str(), ERROR_LOG_FMT(COMMON, "CreateEmptyFile: failed {}: {}", filename, LastStrerrorString());
LastStrerrorString().c_str());
return false; return false;
} }
@ -413,7 +409,7 @@ bool CreateEmptyFile(const std::string& filename)
// Recursive or non-recursive list of files and directories under directory. // Recursive or non-recursive list of files and directories under directory.
FSTEntry ScanDirectoryTree(const std::string& directory, bool recursive) FSTEntry ScanDirectoryTree(const std::string& directory, bool recursive)
{ {
INFO_LOG(COMMON, "ScanDirectoryTree: directory %s", directory.c_str()); INFO_LOG_FMT(COMMON, "ScanDirectoryTree: directory {}", directory);
FSTEntry parent_entry; FSTEntry parent_entry;
parent_entry.physicalName = directory; parent_entry.physicalName = directory;
parent_entry.isDirectory = true; parent_entry.isDirectory = true;
@ -480,7 +476,7 @@ FSTEntry ScanDirectoryTree(const std::string& directory, bool recursive)
// Deletes the given directory and anything under it. Returns true on success. // Deletes the given directory and anything under it. Returns true on success.
bool DeleteDirRecursively(const std::string& directory) bool DeleteDirRecursively(const std::string& directory)
{ {
INFO_LOG(COMMON, "DeleteDirRecursively: %s", directory.c_str()); INFO_LOG_FMT(COMMON, "DeleteDirRecursively: {}", directory);
bool success = true; bool success = true;
#ifdef _WIN32 #ifdef _WIN32
@ -613,7 +609,7 @@ std::string GetCurrentDir()
char* dir = __getcwd(nullptr, 0); char* dir = __getcwd(nullptr, 0);
if (!dir) if (!dir)
{ {
ERROR_LOG(COMMON, "GetCurrentDirectory failed: %s", LastStrerrorString().c_str()); ERROR_LOG_FMT(COMMON, "GetCurrentDirectory failed: {}", LastStrerrorString());
return ""; return "";
} }
std::string strDir = dir; std::string strDir = dir;
@ -766,14 +762,14 @@ std::string GetSysDirectory()
#endif #endif
sysDir += DIR_SEP; sysDir += DIR_SEP;
INFO_LOG(COMMON, "GetSysDirectory: Setting to %s:", sysDir.c_str()); INFO_LOG_FMT(COMMON, "GetSysDirectory: Setting to {}:", sysDir);
return sysDir; return sysDir;
} }
#ifdef ANDROID #ifdef ANDROID
void SetSysDirectory(const std::string& path) void SetSysDirectory(const std::string& path)
{ {
INFO_LOG(COMMON, "Setting Sys directory to %s", path.c_str()); INFO_LOG_FMT(COMMON, "Setting Sys directory to {}", path);
s_android_sys_directory = path; s_android_sys_directory = path;
} }
#endif #endif

View File

@ -2439,7 +2439,7 @@ static void* GetFuncAddress(GLContext* context, const std::string& name, void**
*func = dlsym(RTLD_NEXT, name.c_str()); *func = dlsym(RTLD_NEXT, name.c_str());
#endif #endif
if (*func == nullptr) if (*func == nullptr)
ERROR_LOG(VIDEO, "Couldn't load function %s", name.c_str()); ERROR_LOG_FMT(VIDEO, "Couldn't load function {}", name);
} }
return *func; return *func;
} }

View File

@ -30,7 +30,7 @@ static bool AttachContextToView(NSOpenGLContext* context, NSView* view, u32* wid
NSWindow* window = [view window]; NSWindow* window = [view window];
if (window == nil) if (window == nil)
{ {
ERROR_LOG(VIDEO, "failed to get NSWindow"); ERROR_LOG_FMT(VIDEO, "failed to get NSWindow");
return false; return false;
} }
@ -83,14 +83,14 @@ bool GLContextAGL::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor
m_pixel_format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr]; m_pixel_format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
if (m_pixel_format == nil) if (m_pixel_format == nil)
{ {
ERROR_LOG(VIDEO, "failed to create pixel format"); ERROR_LOG_FMT(VIDEO, "failed to create pixel format");
return false; return false;
} }
m_context = [[NSOpenGLContext alloc] initWithFormat:m_pixel_format shareContext:nil]; m_context = [[NSOpenGLContext alloc] initWithFormat:m_pixel_format shareContext:nil];
if (m_context == nil) if (m_context == nil)
{ {
ERROR_LOG(VIDEO, "failed to create context"); ERROR_LOG_FMT(VIDEO, "failed to create context");
return false; return false;
} }
@ -112,7 +112,7 @@ std::unique_ptr<GLContext> GLContextAGL::CreateSharedContext()
shareContext:m_context]; shareContext:m_context];
if (new_agl_context == nil) if (new_agl_context == nil)
{ {
ERROR_LOG(VIDEO, "failed to create shared context"); ERROR_LOG_FMT(VIDEO, "failed to create shared context");
return nullptr; return nullptr;
} }

View File

@ -78,7 +78,7 @@ void GLContextEGL::DetectMode()
// Get how many configs there are // Get how many configs there are
if (!eglChooseConfig(m_egl_display, attribs, nullptr, 0, &num_configs)) if (!eglChooseConfig(m_egl_display, attribs, nullptr, 0, &num_configs))
{ {
INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config"); INFO_LOG_FMT(VIDEO, "Error: couldn't get an EGL visual config");
continue; continue;
} }
@ -87,7 +87,7 @@ void GLContextEGL::DetectMode()
// Get all the configurations // Get all the configurations
if (!eglChooseConfig(m_egl_display, attribs, config, num_configs, &num_configs)) if (!eglChooseConfig(m_egl_display, attribs, config, num_configs, &num_configs))
{ {
INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config"); INFO_LOG_FMT(VIDEO, "Error: couldn't get an EGL visual config");
delete[] config; delete[] config;
continue; continue;
} }
@ -110,18 +110,18 @@ void GLContextEGL::DetectMode()
if (supportsGL) if (supportsGL)
{ {
INFO_LOG(VIDEO, "Using OpenGL"); INFO_LOG_FMT(VIDEO, "Using OpenGL");
m_opengl_mode = Mode::OpenGL; m_opengl_mode = Mode::OpenGL;
} }
else if (supportsGLES3) else if (supportsGLES3)
{ {
INFO_LOG(VIDEO, "Using OpenGL|ES"); INFO_LOG_FMT(VIDEO, "Using OpenGL|ES");
m_opengl_mode = Mode::OpenGLES; m_opengl_mode = Mode::OpenGLES;
} }
else else
{ {
// Errored before we found a mode // Errored before we found a mode
ERROR_LOG(VIDEO, "Error: Failed to detect OpenGL flavour, falling back to OpenGL"); ERROR_LOG_FMT(VIDEO, "Error: Failed to detect OpenGL flavour, falling back to OpenGL");
// This will fail to create a context, as it'll try to use the same attribs we just failed to // This will fail to create a context, as it'll try to use the same attribs we just failed to
// find a matching config with // find a matching config with
m_opengl_mode = Mode::OpenGL; m_opengl_mode = Mode::OpenGL;
@ -149,13 +149,13 @@ bool GLContextEGL::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor
m_egl_display = OpenEGLDisplay(); m_egl_display = OpenEGLDisplay();
if (!m_egl_display) if (!m_egl_display)
{ {
INFO_LOG(VIDEO, "Error: eglGetDisplay() failed"); INFO_LOG_FMT(VIDEO, "Error: eglGetDisplay() failed");
return false; return false;
} }
if (!eglInitialize(m_egl_display, &egl_major, &egl_minor)) if (!eglInitialize(m_egl_display, &egl_major, &egl_minor))
{ {
INFO_LOG(VIDEO, "Error: eglInitialize() failed"); INFO_LOG_FMT(VIDEO, "Error: eglInitialize() failed");
return false; return false;
} }
@ -191,13 +191,13 @@ bool GLContextEGL::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor
ctx_attribs = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE}; ctx_attribs = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE};
break; break;
default: default:
ERROR_LOG(VIDEO, "Unknown opengl mode set"); ERROR_LOG_FMT(VIDEO, "Unknown opengl mode set");
return false; return false;
} }
if (!eglChooseConfig(m_egl_display, attribs, &m_config, 1, &num_configs)) if (!eglChooseConfig(m_egl_display, attribs, &m_config, 1, &num_configs))
{ {
INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config"); INFO_LOG_FMT(VIDEO, "Error: couldn't get an EGL visual config");
return false; return false;
} }
@ -247,13 +247,13 @@ bool GLContextEGL::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor
if (!m_egl_context) if (!m_egl_context)
{ {
INFO_LOG(VIDEO, "Error: eglCreateContext failed"); INFO_LOG_FMT(VIDEO, "Error: eglCreateContext failed");
return false; return false;
} }
if (!CreateWindowSurface()) if (!CreateWindowSurface())
{ {
ERROR_LOG(VIDEO, "Error: CreateWindowSurface failed 0x%04x", eglGetError()); ERROR_LOG_FMT(VIDEO, "Error: CreateWindowSurface failed {:#06x}", eglGetError());
return false; return false;
} }
@ -267,7 +267,7 @@ std::unique_ptr<GLContext> GLContextEGL::CreateSharedContext()
eglCreateContext(m_egl_display, m_config, m_egl_context, m_attribs.data()); eglCreateContext(m_egl_display, m_config, m_egl_context, m_attribs.data());
if (!new_egl_context) if (!new_egl_context)
{ {
INFO_LOG(VIDEO, "Error: eglCreateContext failed 0x%04x", eglGetError()); INFO_LOG_FMT(VIDEO, "Error: eglCreateContext failed {:#06x}", eglGetError());
return nullptr; return nullptr;
} }
@ -281,7 +281,7 @@ std::unique_ptr<GLContext> GLContextEGL::CreateSharedContext()
new_context->m_is_shared = true; new_context->m_is_shared = true;
if (!new_context->CreateWindowSurface()) if (!new_context->CreateWindowSurface())
{ {
ERROR_LOG(VIDEO, "Error: CreateWindowSurface failed 0x%04x", eglGetError()); ERROR_LOG_FMT(VIDEO, "Error: CreateWindowSurface failed {:#06x}", eglGetError());
return nullptr; return nullptr;
} }
@ -296,7 +296,7 @@ bool GLContextEGL::CreateWindowSurface()
m_egl_surface = eglCreateWindowSurface(m_egl_display, m_config, native_window, nullptr); m_egl_surface = eglCreateWindowSurface(m_egl_display, m_config, native_window, nullptr);
if (!m_egl_surface) if (!m_egl_surface)
{ {
INFO_LOG(VIDEO, "Error: eglCreateWindowSurface failed"); INFO_LOG_FMT(VIDEO, "Error: eglCreateWindowSurface failed");
return false; return false;
} }
@ -305,7 +305,7 @@ bool GLContextEGL::CreateWindowSurface()
if (!eglQuerySurface(m_egl_display, m_egl_surface, EGL_WIDTH, &surface_width) || if (!eglQuerySurface(m_egl_display, m_egl_surface, EGL_WIDTH, &surface_width) ||
!eglQuerySurface(m_egl_display, m_egl_surface, EGL_HEIGHT, &surface_height)) !eglQuerySurface(m_egl_display, m_egl_surface, EGL_HEIGHT, &surface_height))
{ {
WARN_LOG(VIDEO, WARN_LOG_FMT(VIDEO,
"Failed to get surface dimensions via eglQuerySurface. Size may be incorrect."); "Failed to get surface dimensions via eglQuerySurface. Size may be incorrect.");
} }
m_backbuffer_width = static_cast<int>(surface_width); m_backbuffer_width = static_cast<int>(surface_width);
@ -319,7 +319,7 @@ bool GLContextEGL::CreateWindowSurface()
m_egl_surface = eglCreatePbufferSurface(m_egl_display, m_config, attrib_list); m_egl_surface = eglCreatePbufferSurface(m_egl_display, m_config, attrib_list);
if (!m_egl_surface) if (!m_egl_surface)
{ {
INFO_LOG(VIDEO, "Error: eglCreatePbufferSurface failed"); INFO_LOG_FMT(VIDEO, "Error: eglCreatePbufferSurface failed");
return false; return false;
} }
} }
@ -338,7 +338,7 @@ void GLContextEGL::DestroyWindowSurface()
if (eglGetCurrentSurface(EGL_DRAW) == m_egl_surface) if (eglGetCurrentSurface(EGL_DRAW) == m_egl_surface)
eglMakeCurrent(m_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglMakeCurrent(m_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (!eglDestroySurface(m_egl_display, m_egl_surface)) if (!eglDestroySurface(m_egl_display, m_egl_surface))
NOTICE_LOG(VIDEO, "Could not destroy window surface."); NOTICE_LOG_FMT(VIDEO, "Could not destroy window surface.");
m_egl_surface = EGL_NO_SURFACE; m_egl_surface = EGL_NO_SURFACE;
} }
@ -370,9 +370,9 @@ void GLContextEGL::DestroyContext()
if (eglGetCurrentContext() == m_egl_context) if (eglGetCurrentContext() == m_egl_context)
eglMakeCurrent(m_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglMakeCurrent(m_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (!eglDestroyContext(m_egl_display, m_egl_context)) if (!eglDestroyContext(m_egl_display, m_egl_context))
NOTICE_LOG(VIDEO, "Could not destroy drawing context."); NOTICE_LOG_FMT(VIDEO, "Could not destroy drawing context.");
if (!m_is_shared && !eglTerminate(m_egl_display)) if (!m_is_shared && !eglTerminate(m_egl_display))
NOTICE_LOG(VIDEO, "Could not destroy display connection."); NOTICE_LOG_FMT(VIDEO, "Could not destroy display connection.");
m_egl_context = EGL_NO_CONTEXT; m_egl_context = EGL_NO_CONTEXT;
m_egl_display = EGL_NO_DISPLAY; m_egl_display = EGL_NO_DISPLAY;
} }

View File

@ -54,11 +54,18 @@ void GLContextGLX::SwapInterval(int Interval)
// Try EXT_swap_control, then MESA_swap_control. // Try EXT_swap_control, then MESA_swap_control.
if (glXSwapIntervalEXTPtr) if (glXSwapIntervalEXTPtr)
{
glXSwapIntervalEXTPtr(m_display, m_drawable, Interval); glXSwapIntervalEXTPtr(m_display, m_drawable, Interval);
}
else if (glXSwapIntervalMESAPtr) else if (glXSwapIntervalMESAPtr)
{
glXSwapIntervalMESAPtr(static_cast<unsigned int>(Interval)); glXSwapIntervalMESAPtr(static_cast<unsigned int>(Interval));
}
else else
ERROR_LOG(VIDEO, "No support for SwapInterval (framerate clamped to monitor refresh rate)."); {
ERROR_LOG_FMT(VIDEO,
"No support for SwapInterval (framerate clamped to monitor refresh rate).");
}
} }
void* GLContextGLX::GetFuncAddress(const std::string& name) void* GLContextGLX::GetFuncAddress(const std::string& name)
@ -83,7 +90,7 @@ bool GLContextGLX::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor
glXQueryVersion(m_display, &glxMajorVersion, &glxMinorVersion); glXQueryVersion(m_display, &glxMajorVersion, &glxMinorVersion);
if (glxMajorVersion < 1 || (glxMajorVersion == 1 && glxMinorVersion < 4)) if (glxMajorVersion < 1 || (glxMajorVersion == 1 && glxMinorVersion < 4))
{ {
ERROR_LOG(VIDEO, "glX-Version %d.%d detected, but need at least 1.4", glxMajorVersion, ERROR_LOG_FMT(VIDEO, "glX-Version {}.{} detected, but need at least 1.4", glxMajorVersion,
glxMinorVersion); glxMinorVersion);
return false; return false;
} }
@ -93,7 +100,7 @@ bool GLContextGLX::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor
(PFNGLXCREATECONTEXTATTRIBSPROC)GetFuncAddress("glXCreateContextAttribsARB"); (PFNGLXCREATECONTEXTATTRIBSPROC)GetFuncAddress("glXCreateContextAttribsARB");
if (!glXCreateContextAttribs) if (!glXCreateContextAttribs)
{ {
ERROR_LOG(VIDEO, ERROR_LOG_FMT(VIDEO,
"glXCreateContextAttribsARB not found, do you support GLX_ARB_create_context?"); "glXCreateContextAttribsARB not found, do you support GLX_ARB_create_context?");
return false; return false;
} }
@ -124,7 +131,7 @@ bool GLContextGLX::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor
GLXFBConfig* fbc = glXChooseFBConfig(m_display, screen, visual_attribs, &fbcount); GLXFBConfig* fbc = glXChooseFBConfig(m_display, screen, visual_attribs, &fbcount);
if (!fbc || !fbcount) if (!fbc || !fbcount)
{ {
ERROR_LOG(VIDEO, "Failed to retrieve a framebuffer config"); ERROR_LOG_FMT(VIDEO, "Failed to retrieve a framebuffer config");
return false; return false;
} }
m_fbconfig = *fbc; m_fbconfig = *fbc;
@ -150,7 +157,8 @@ bool GLContextGLX::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor
continue; continue;
// Got a context. // Got a context.
INFO_LOG(VIDEO, "Created a GLX context with version %d.%d", version.first, version.second); INFO_LOG_FMT(VIDEO, "Created a GLX context with version {}.{}", version.first,
version.second);
m_attribs.insert(m_attribs.end(), context_attribs.begin(), context_attribs.end()); m_attribs.insert(m_attribs.end(), context_attribs.begin(), context_attribs.end());
break; break;
} }
@ -169,7 +177,7 @@ bool GLContextGLX::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor
} }
if (!m_context || s_glxError) if (!m_context || s_glxError)
{ {
ERROR_LOG(VIDEO, "Unable to create GL context."); ERROR_LOG_FMT(VIDEO, "Unable to create GL context.");
XSetErrorHandler(oldHandler); XSetErrorHandler(oldHandler);
return false; return false;
} }
@ -206,7 +214,7 @@ bool GLContextGLX::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor
if (!CreateWindowSurface(reinterpret_cast<Window>(wsi.render_surface))) if (!CreateWindowSurface(reinterpret_cast<Window>(wsi.render_surface)))
{ {
ERROR_LOG(VIDEO, "Error: CreateWindowSurface failed\n"); ERROR_LOG_FMT(VIDEO, "Error: CreateWindowSurface failed\n");
XSetErrorHandler(oldHandler); XSetErrorHandler(oldHandler);
return false; return false;
} }
@ -227,7 +235,7 @@ std::unique_ptr<GLContext> GLContextGLX::CreateSharedContext()
if (!new_glx_context || s_glxError) if (!new_glx_context || s_glxError)
{ {
ERROR_LOG(VIDEO, "Unable to create GL context."); ERROR_LOG_FMT(VIDEO, "Unable to create GL context.");
XSetErrorHandler(oldHandler); XSetErrorHandler(oldHandler);
return nullptr; return nullptr;
} }
@ -242,7 +250,7 @@ std::unique_ptr<GLContext> GLContextGLX::CreateSharedContext()
if (m_supports_pbuffer && !new_context->CreateWindowSurface(None)) if (m_supports_pbuffer && !new_context->CreateWindowSurface(None))
{ {
ERROR_LOG(VIDEO, "Error: CreateWindowSurface failed"); ERROR_LOG_FMT(VIDEO, "Error: CreateWindowSurface failed");
XSetErrorHandler(oldHandler); XSetErrorHandler(oldHandler);
return nullptr; return nullptr;
} }

View File

@ -162,10 +162,10 @@ GLContextWGL::~GLContextWGL()
if (m_rc) if (m_rc)
{ {
if (wglGetCurrentContext() == m_rc && !wglMakeCurrent(m_dc, nullptr)) if (wglGetCurrentContext() == m_rc && !wglMakeCurrent(m_dc, nullptr))
NOTICE_LOG(VIDEO, "Could not release drawing context."); NOTICE_LOG_FMT(VIDEO, "Could not release drawing context.");
if (!wglDeleteContext(m_rc)) if (!wglDeleteContext(m_rc))
ERROR_LOG(VIDEO, "Attempt to release rendering context failed."); ERROR_LOG_FMT(VIDEO, "Attempt to release rendering context failed.");
m_rc = nullptr; m_rc = nullptr;
} }
@ -183,7 +183,7 @@ GLContextWGL::~GLContextWGL()
else else
{ {
if (!ReleaseDC(m_window_handle, m_dc)) if (!ReleaseDC(m_window_handle, m_dc))
ERROR_LOG(VIDEO, "Attempt to release device context failed."); ERROR_LOG_FMT(VIDEO, "Attempt to release device context failed.");
m_dc = nullptr; m_dc = nullptr;
} }
@ -198,9 +198,14 @@ bool GLContextWGL::IsHeadless() const
void GLContextWGL::SwapInterval(int interval) void GLContextWGL::SwapInterval(int interval)
{ {
if (wglSwapIntervalEXT) if (wglSwapIntervalEXT)
{
wglSwapIntervalEXT(interval); wglSwapIntervalEXT(interval);
}
else else
ERROR_LOG(VIDEO, "No support for SwapInterval (framerate clamped to monitor refresh rate)."); {
ERROR_LOG_FMT(VIDEO,
"No support for SwapInterval (framerate clamped to monitor refresh rate).");
}
} }
void GLContextWGL::Swap() void GLContextWGL::Swap()
{ {
@ -331,7 +336,7 @@ bool GLContextWGL::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor
} }
else else
{ {
WARN_LOG(VIDEO, "Failed to create a core OpenGL context. Using fallback context."); WARN_LOG_FMT(VIDEO, "Failed to create a core OpenGL context. Using fallback context.");
} }
} }
@ -367,7 +372,7 @@ HGLRC GLContextWGL::CreateCoreContext(HDC dc, HGLRC share_context)
{ {
if (!wglCreateContextAttribsARB) if (!wglCreateContextAttribsARB)
{ {
WARN_LOG(VIDEO, "Missing WGL_ARB_create_context extension"); WARN_LOG_FMT(VIDEO, "Missing WGL_ARB_create_context extension");
return nullptr; return nullptr;
} }
@ -400,18 +405,18 @@ HGLRC GLContextWGL::CreateCoreContext(HDC dc, HGLRC share_context)
{ {
if (!wglShareLists(share_context, core_context)) if (!wglShareLists(share_context, core_context))
{ {
ERROR_LOG(VIDEO, "wglShareLists failed"); ERROR_LOG_FMT(VIDEO, "wglShareLists failed");
wglDeleteContext(core_context); wglDeleteContext(core_context);
return nullptr; return nullptr;
} }
} }
INFO_LOG(VIDEO, "WGL: Created a GL %d.%d core context", version.first, version.second); INFO_LOG_FMT(VIDEO, "WGL: Created a GL {}.{} core context", version.first, version.second);
return core_context; return core_context;
} }
} }
WARN_LOG(VIDEO, "Unable to create a core OpenGL context of an acceptable version"); WARN_LOG_FMT(VIDEO, "Unable to create a core OpenGL context of an acceptable version");
return nullptr; return nullptr;
} }
@ -421,7 +426,7 @@ bool GLContextWGL::CreatePBuffer(HDC onscreen_dc, int width, int height, HANDLE*
if (!wglChoosePixelFormatARB || !wglCreatePbufferARB || !wglGetPbufferDCARB || if (!wglChoosePixelFormatARB || !wglCreatePbufferARB || !wglGetPbufferDCARB ||
!wglReleasePbufferDCARB || !wglDestroyPbufferARB) !wglReleasePbufferDCARB || !wglDestroyPbufferARB)
{ {
ERROR_LOG(VIDEO, "Missing WGL_ARB_pbuffer extension"); ERROR_LOG_FMT(VIDEO, "Missing WGL_ARB_pbuffer extension");
return false; return false;
} }
@ -448,7 +453,7 @@ bool GLContextWGL::CreatePBuffer(HDC onscreen_dc, int width, int height, HANDLE*
if (!wglChoosePixelFormatARB(onscreen_dc, pf_iattribs.data(), pf_fattribs.data(), 1, if (!wglChoosePixelFormatARB(onscreen_dc, pf_iattribs.data(), pf_fattribs.data(), 1,
&pixel_format, &num_pixel_formats)) &pixel_format, &num_pixel_formats))
{ {
ERROR_LOG(VIDEO, "Failed to obtain a compatible pbuffer pixel format"); ERROR_LOG_FMT(VIDEO, "Failed to obtain a compatible pbuffer pixel format");
return false; return false;
} }
@ -458,14 +463,14 @@ bool GLContextWGL::CreatePBuffer(HDC onscreen_dc, int width, int height, HANDLE*
wglCreatePbufferARB(onscreen_dc, pixel_format, width, height, pb_attribs.data()); wglCreatePbufferARB(onscreen_dc, pixel_format, width, height, pb_attribs.data());
if (!pbuffer) if (!pbuffer)
{ {
ERROR_LOG(VIDEO, "Failed to create pbuffer"); ERROR_LOG_FMT(VIDEO, "Failed to create pbuffer");
return false; return false;
} }
HDC dc = wglGetPbufferDCARB(pbuffer); HDC dc = wglGetPbufferDCARB(pbuffer);
if (!dc) if (!dc)
{ {
ERROR_LOG(VIDEO, "Failed to get drawing context from pbuffer"); ERROR_LOG_FMT(VIDEO, "Failed to get drawing context from pbuffer");
wglDestroyPbufferARB(pbuffer); wglDestroyPbufferARB(pbuffer);
return false; return false;
} }

View File

@ -31,15 +31,15 @@ GLuint CompileProgram(const std::string& vertexShader, const std::string& fragme
if (Result && stringBufferUsage) if (Result && stringBufferUsage)
{ {
ERROR_LOG(VIDEO, "GLSL vertex shader warnings:\n%s%s", stringBuffer, vertexShader.c_str()); ERROR_LOG_FMT(VIDEO, "GLSL vertex shader warnings:\n{}{}", stringBuffer, vertexShader);
} }
else if (!Result) else if (!Result)
{ {
ERROR_LOG(VIDEO, "GLSL vertex shader error:\n%s%s", stringBuffer, vertexShader.c_str()); ERROR_LOG_FMT(VIDEO, "GLSL vertex shader error:\n{}{}", stringBuffer, vertexShader);
} }
else else
{ {
INFO_LOG(VIDEO, "GLSL vertex shader compiled:\n%s", vertexShader.c_str()); INFO_LOG_FMT(VIDEO, "GLSL vertex shader compiled:\n{}", vertexShader);
} }
bool shader_errors = !Result; bool shader_errors = !Result;
@ -55,15 +55,15 @@ GLuint CompileProgram(const std::string& vertexShader, const std::string& fragme
if (Result && stringBufferUsage) if (Result && stringBufferUsage)
{ {
ERROR_LOG(VIDEO, "GLSL fragment shader warnings:\n%s%s", stringBuffer, fragmentShader.c_str()); ERROR_LOG_FMT(VIDEO, "GLSL fragment shader warnings:\n{}{}", stringBuffer, fragmentShader);
} }
else if (!Result) else if (!Result)
{ {
ERROR_LOG(VIDEO, "GLSL fragment shader error:\n%s%s", stringBuffer, fragmentShader.c_str()); ERROR_LOG_FMT(VIDEO, "GLSL fragment shader error:\n{}{}", stringBuffer, fragmentShader);
} }
else else
{ {
INFO_LOG(VIDEO, "GLSL fragment shader compiled:\n%s", fragmentShader.c_str()); INFO_LOG_FMT(VIDEO, "GLSL fragment shader compiled:\n{}", fragmentShader);
} }
shader_errors |= !Result; shader_errors |= !Result;
@ -79,13 +79,12 @@ GLuint CompileProgram(const std::string& vertexShader, const std::string& fragme
if (Result && stringBufferUsage) if (Result && stringBufferUsage)
{ {
ERROR_LOG(VIDEO, "GLSL linker warnings:\n%s%s%s", stringBuffer, vertexShader.c_str(), ERROR_LOG_FMT(VIDEO, "GLSL linker warnings:\n{}{}{}", stringBuffer, vertexShader,
fragmentShader.c_str()); fragmentShader);
} }
else if (!Result && !shader_errors) else if (!Result && !shader_errors)
{ {
ERROR_LOG(VIDEO, "GLSL linker error:\n%s%s%s", stringBuffer, vertexShader.c_str(), ERROR_LOG_FMT(VIDEO, "GLSL linker error:\n{}{}{}", stringBuffer, vertexShader, fragmentShader);
fragmentShader.c_str());
} }
#endif #endif

View File

@ -210,7 +210,7 @@ HttpRequest::Response HttpRequest::Impl::Fetch(const std::string& url, Method me
const CURLcode res = curl_easy_perform(m_curl.get()); const CURLcode res = curl_easy_perform(m_curl.get());
if (res != CURLE_OK) if (res != CURLE_OK)
{ {
ERROR_LOG(COMMON, "Failed to %s %s: %s", type, url.c_str(), m_error_string.c_str()); ERROR_LOG_FMT(COMMON, "Failed to {} {}: {}", type, url, m_error_string);
return {}; return {};
} }
@ -221,8 +221,8 @@ HttpRequest::Response HttpRequest::Impl::Fetch(const std::string& url, Method me
curl_easy_getinfo(m_curl.get(), CURLINFO_RESPONSE_CODE, &response_code); curl_easy_getinfo(m_curl.get(), CURLINFO_RESPONSE_CODE, &response_code);
if (response_code != 200) if (response_code != 200)
{ {
ERROR_LOG(COMMON, "Failed to %s %s: server replied with code %li and body\n\x1b[0m%.*s", type, ERROR_LOG_FMT(COMMON, "Failed to {} {}: server replied with code {} and body\n\x1b[0m{:.{}}",
url.c_str(), response_code, static_cast<int>(buffer.size()), buffer.data()); type, url, response_code, buffer.data(), static_cast<int>(buffer.size()));
return {}; return {};
} }

View File

@ -60,7 +60,7 @@ static int AshmemCreateFileMapping(const char* name, size_t size)
if (ret < 0) if (ret < 0)
{ {
close(fd); close(fd);
NOTICE_LOG(MEMMAP, "Ashmem returned error: 0x%08x", ret); NOTICE_LOG_FMT(MEMMAP, "Ashmem returned error: {:#010x}", ret);
return ret; return ret;
} }
return fd; return fd;
@ -77,7 +77,7 @@ void MemArena::GrabSHMSegment(size_t size)
fd = AshmemCreateFileMapping(("dolphin-emu." + std::to_string(getpid())).c_str(), size); fd = AshmemCreateFileMapping(("dolphin-emu." + std::to_string(getpid())).c_str(), size);
if (fd < 0) if (fd < 0)
{ {
NOTICE_LOG(MEMMAP, "Ashmem allocation failed"); NOTICE_LOG_FMT(MEMMAP, "Ashmem allocation failed");
return; return;
} }
#else #else
@ -85,12 +85,12 @@ void MemArena::GrabSHMSegment(size_t size)
fd = shm_open(file_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600); fd = shm_open(file_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600);
if (fd == -1) if (fd == -1)
{ {
ERROR_LOG(MEMMAP, "shm_open failed: %s", strerror(errno)); ERROR_LOG_FMT(MEMMAP, "shm_open failed: {}", strerror(errno));
return; return;
} }
shm_unlink(file_name.c_str()); shm_unlink(file_name.c_str());
if (ftruncate(fd, size) < 0) if (ftruncate(fd, size) < 0)
ERROR_LOG(MEMMAP, "Failed to allocate low memory space"); ERROR_LOG_FMT(MEMMAP, "Failed to allocate low memory space");
#endif #endif
} }
@ -114,7 +114,7 @@ void* MemArena::CreateView(s64 offset, size_t size, void* base)
if (retval == MAP_FAILED) if (retval == MAP_FAILED)
{ {
NOTICE_LOG(MEMMAP, "mmap failed"); NOTICE_LOG_FMT(MEMMAP, "mmap failed");
return nullptr; return nullptr;
} }
else else

View File

@ -75,7 +75,7 @@ void* AllocateAlignedMemory(size_t size, size_t alignment)
#else #else
void* ptr = nullptr; void* ptr = nullptr;
if (posix_memalign(&ptr, alignment, size) != 0) if (posix_memalign(&ptr, alignment, size) != 0)
ERROR_LOG(MEMMAP, "Failed to allocate aligned memory"); ERROR_LOG_FMT(MEMMAP, "Failed to allocate aligned memory");
#endif #endif
if (ptr == nullptr) if (ptr == nullptr)

View File

@ -112,7 +112,7 @@ bool MsgAlert(bool yes_no, MsgType style, const char* format, ...)
CharArrayFromFormatV(buffer, sizeof(buffer) - 1, s_str_translator(format).c_str(), args); CharArrayFromFormatV(buffer, sizeof(buffer) - 1, s_str_translator(format).c_str(), args);
va_end(args); va_end(args);
ERROR_LOG(MASTER_LOG, "%s: %s", caption, buffer); ERROR_LOG_FMT(MASTER_LOG, "{}: {}", caption, buffer);
// Don't ignore questions, especially AskYesNo, PanicYesNo could be ignored // Don't ignore questions, especially AskYesNo, PanicYesNo could be ignored
if (s_msg_handler != nullptr && if (s_msg_handler != nullptr &&

View File

@ -35,7 +35,6 @@
#include "Common/SDCardUtil.h" #include "Common/SDCardUtil.h"
#include <algorithm> #include <algorithm>
#include <cinttypes>
#include <cstddef> #include <cstddef>
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
@ -208,8 +207,7 @@ bool SDCardCreate(u64 disk_size /*in MB*/, const std::string& filename)
if (disk_size < 0x800000 || disk_size > 0x800000000ULL) if (disk_size < 0x800000 || disk_size > 0x800000000ULL)
{ {
ERROR_LOG(COMMON, ERROR_LOG_FMT(COMMON, "Trying to create SD Card image of size {}MB is out of range (8MB-32GB)",
"Trying to create SD Card image of size %" PRIu64 "MB is out of range (8MB-32GB)",
disk_size / (1024 * 1024)); disk_size / (1024 * 1024));
return false; return false;
} }
@ -224,7 +222,7 @@ bool SDCardCreate(u64 disk_size /*in MB*/, const std::string& filename)
File::IOFile file(filename, "wb"); File::IOFile file(filename, "wb");
if (!file) if (!file)
{ {
ERROR_LOG(COMMON, "Could not create file '%s', aborting...", filename.c_str()); ERROR_LOG_FMT(COMMON, "Could not create file '{}', aborting...", filename);
return false; return false;
} }
@ -285,9 +283,9 @@ bool SDCardCreate(u64 disk_size /*in MB*/, const std::string& filename)
return true; return true;
FailWrite: FailWrite:
ERROR_LOG(COMMON, "Could not write to '%s', aborting...", filename.c_str()); ERROR_LOG_FMT(COMMON, "Could not write to '{}', aborting...", filename);
if (unlink(filename.c_str()) < 0) if (unlink(filename.c_str()) < 0)
ERROR_LOG(COMMON, "unlink(%s) failed: %s", filename.c_str(), LastStrerrorString().c_str()); ERROR_LOG_FMT(COMMON, "unlink({}) failed: {}", filename, LastStrerrorString());
return false; return false;
} }
} // namespace Common } // namespace Common

View File

@ -179,7 +179,7 @@ std::string StringFromFormatV(const char* format, va_list args)
#endif #endif
if (vasprintf(&buf, format, args) < 0) if (vasprintf(&buf, format, args) < 0)
{ {
ERROR_LOG(COMMON, "Unable to allocate memory for string"); ERROR_LOG_FMT(COMMON, "Unable to allocate memory for string");
buf = nullptr; buf = nullptr;
} }
@ -442,24 +442,22 @@ std::wstring CPToUTF16(u32 code_page, std::string_view input)
std::string UTF16ToCP(u32 code_page, std::wstring_view input) std::string UTF16ToCP(u32 code_page, std::wstring_view input)
{ {
std::string output; if (input.empty())
return {};
if (0 != input.size())
{
// "If cchWideChar [input buffer size] is set to 0, the function fails." -MSDN // "If cchWideChar [input buffer size] is set to 0, the function fails." -MSDN
auto const size = WideCharToMultiByte( auto const size = WideCharToMultiByte(code_page, 0, input.data(), static_cast<int>(input.size()),
code_page, 0, input.data(), static_cast<int>(input.size()), nullptr, 0, nullptr, nullptr); nullptr, 0, nullptr, nullptr);
output.resize(size); std::string output(size, '\0');
if (size != WideCharToMultiByte(code_page, 0, input.data(), static_cast<int>(input.size()), if (size != WideCharToMultiByte(code_page, 0, input.data(), static_cast<int>(input.size()),
&output[0], static_cast<int>(output.size()), nullptr, nullptr)) output.data(), static_cast<int>(output.size()), nullptr, nullptr))
{ {
const DWORD error_code = GetLastError(); const DWORD error_code = GetLastError();
ERROR_LOG(COMMON, "WideCharToMultiByte Error in String '%s': %lu", ERROR_LOG_FMT(COMMON, "WideCharToMultiByte Error in String '{}': {}", WStringToUTF8(input),
std::wstring(input).c_str(), error_code); error_code);
output.clear(); return {};
}
} }
return output; return output;
@ -508,7 +506,7 @@ std::string CodeTo(const char* tocode, const char* fromcode, std::basic_string_v
iconv_t const conv_desc = iconv_open(tocode, fromcode); iconv_t const conv_desc = iconv_open(tocode, fromcode);
if ((iconv_t)-1 == conv_desc) if ((iconv_t)-1 == conv_desc)
{ {
ERROR_LOG(COMMON, "Iconv initialization failure [%s]: %s", fromcode, strerror(errno)); ERROR_LOG_FMT(COMMON, "Iconv initialization failure [{}]: {}", fromcode, strerror(errno));
} }
else else
{ {
@ -541,7 +539,7 @@ std::string CodeTo(const char* tocode, const char* fromcode, std::basic_string_v
} }
else else
{ {
ERROR_LOG(COMMON, "iconv failure [%s]: %s", fromcode, strerror(errno)); ERROR_LOG_FMT(COMMON, "iconv failure [{}]: {}", fromcode, strerror(errno));
break; break;
} }
} }

View File

@ -36,10 +36,10 @@ void SymbolDB::List()
{ {
for (const auto& func : m_functions) for (const auto& func : m_functions)
{ {
DEBUG_LOG(OSHLE, "%s @ %08x: %i bytes (hash %08x) : %i calls", func.second.name.c_str(), DEBUG_LOG_FMT(OSHLE, "{} @ {:08x}: {} bytes (hash {:08x}) : {} calls", func.second.name,
func.second.address, func.second.size, func.second.hash, func.second.num_calls); func.second.address, func.second.size, func.second.hash, func.second.num_calls);
} }
INFO_LOG(OSHLE, "%zu functions known in this program above.", m_functions.size()); INFO_LOG_FMT(OSHLE, "{} functions known in this program above.", m_functions.size());
} }
bool SymbolDB::IsEmpty() const bool SymbolDB::IsEmpty() const

View File

@ -93,7 +93,7 @@ bool TraversalClient::TestPacket(u8* data, size_t size, ENetAddress* from)
{ {
if (size < sizeof(TraversalPacket)) if (size < sizeof(TraversalPacket))
{ {
ERROR_LOG(NETPLAY, "Received too-short traversal packet."); ERROR_LOG_FMT(NETPLAY, "Received too-short traversal packet.");
} }
else else
{ {
@ -194,7 +194,7 @@ void TraversalClient::HandleServerPacket(TraversalPacket* packet)
break; break;
} }
default: default:
WARN_LOG(NETPLAY, "Received unknown packet with type %d", packet->type); WARN_LOG_FMT(NETPLAY, "Received unknown packet with type {}", packet->type);
break; break;
} }
if (packet->type != TraversalPacketAck) if (packet->type != TraversalPacketAck)

View File

@ -52,7 +52,7 @@ static bool InitUPnP()
#endif #endif
if (!devlist) if (!devlist)
{ {
WARN_LOG(NETPLAY, "An error occurred trying to discover UPnP devices."); WARN_LOG_FMT(NETPLAY, "An error occurred trying to discover UPnP devices.");
s_error = true; s_error = true;
@ -81,12 +81,12 @@ static bool InitUPnP()
parserootdesc(desc_xml.get(), desc_xml_size, &s_data); parserootdesc(desc_xml.get(), desc_xml_size, &s_data);
GetUPNPUrls(&s_urls, &s_data, dev->descURL, 0); GetUPNPUrls(&s_urls, &s_data, dev->descURL, 0);
NOTICE_LOG(NETPLAY, "Got info from IGD at %s.", dev->descURL); NOTICE_LOG_FMT(NETPLAY, "Got info from IGD at {}.", dev->descURL);
break; break;
} }
else else
{ {
WARN_LOG(NETPLAY, "Error getting info from IGD at %s.", dev->descURL); WARN_LOG_FMT(NETPLAY, "Error getting info from IGD at {}.", dev->descURL);
} }
} }
@ -137,11 +137,11 @@ static void MapPortThread(const u16 port)
{ {
if (InitUPnP() && MapPort(s_our_ip.data(), port)) if (InitUPnP() && MapPort(s_our_ip.data(), port))
{ {
NOTICE_LOG(NETPLAY, "Successfully mapped port %d to %s.", port, s_our_ip.data()); NOTICE_LOG_FMT(NETPLAY, "Successfully mapped port {} to {}.", port, s_our_ip.data());
return; return;
} }
WARN_LOG(NETPLAY, "Failed to map port %d to %s.", port, s_our_ip.data()); WARN_LOG_FMT(NETPLAY, "Failed to map port {} to {}.", port, s_our_ip.data());
} }
// UPnP thread: try to unmap a port // UPnP thread: try to unmap a port

View File

@ -1647,7 +1647,7 @@ void XEmitter::MOV(int bits, const OpArg& a1, const OpArg& a2)
return; return;
} }
if (a1.IsSimpleReg() && a2.IsSimpleReg() && a1.GetSimpleReg() == a2.GetSimpleReg()) if (a1.IsSimpleReg() && a2.IsSimpleReg() && a1.GetSimpleReg() == a2.GetSimpleReg())
ERROR_LOG(DYNA_REC, "Redundant MOV @ %p - bug in JIT?", code); ERROR_LOG_FMT(DYNA_REC, "Redundant MOV @ {} - bug in JIT?", fmt::ptr(code));
WriteNormalOp(bits, NormalOp::MOV, a1, a2); WriteNormalOp(bits, NormalOp::MOV, a1, a2);
} }
void XEmitter::TEST(int bits, const OpArg& a1, const OpArg& a2) void XEmitter::TEST(int bits, const OpArg& a1, const OpArg& a2)