Misc: Replace log printf calls with fmt
This commit is contained in:
@ -283,17 +283,11 @@ public:
|
||||
#if defined(_WIN32)
|
||||
// delete the temporary file
|
||||
if (!DeleteFileW(FileSystem::GetWin32Path(m_temporaryFileName).c_str()))
|
||||
{
|
||||
Log_WarningPrintf(
|
||||
"AtomicUpdatedFileByteStream::~AtomicUpdatedFileByteStream(): Failed to delete temporary file '%s'",
|
||||
m_temporaryFileName.c_str());
|
||||
}
|
||||
Log_WarningFmt("Failed to delete temporary file '{}'", m_temporaryFileName);
|
||||
#else
|
||||
// delete the temporary file
|
||||
if (remove(m_temporaryFileName.c_str()) < 0)
|
||||
Log_WarningPrintf(
|
||||
"AtomicUpdatedFileByteStream::~AtomicUpdatedFileByteStream(): Failed to delete temporary file '%s'",
|
||||
m_temporaryFileName.c_str());
|
||||
Log_WarningFmt("Failed to delete temporary file '{}'", m_temporaryFileName);
|
||||
#endif
|
||||
}
|
||||
else if (!m_committed)
|
||||
@ -317,8 +311,7 @@ public:
|
||||
if (!MoveFileExW(FileSystem::GetWin32Path(m_temporaryFileName).c_str(),
|
||||
FileSystem::GetWin32Path(m_originalFileName).c_str(), MOVEFILE_REPLACE_EXISTING))
|
||||
{
|
||||
Log_WarningPrintf("AtomicUpdatedFileByteStream::Commit(): Failed to rename temporary file '%s' to '%s'",
|
||||
m_temporaryFileName.c_str(), m_originalFileName.c_str());
|
||||
Log_WarningFmt("Failed to rename temporary file '{}' to '{}'", m_temporaryFileName, m_originalFileName);
|
||||
m_discarded = true;
|
||||
}
|
||||
else
|
||||
@ -329,8 +322,7 @@ public:
|
||||
// move the atomic file name to the original file name
|
||||
if (rename(m_temporaryFileName.c_str(), m_originalFileName.c_str()) < 0)
|
||||
{
|
||||
Log_WarningPrintf("AtomicUpdatedFileByteStream::Commit(): Failed to rename temporary file '%s' to '%s'",
|
||||
m_temporaryFileName.c_str(), m_originalFileName.c_str());
|
||||
Log_WarningFmt("Failed to rename temporary file '{}' to '{}'", m_temporaryFileName, m_originalFileName);
|
||||
m_discarded = true;
|
||||
}
|
||||
else
|
||||
|
||||
@ -1766,11 +1766,9 @@ bool FileSystem::RenamePath(const char* old_path, const char* new_path, Error* e
|
||||
const std::wstring old_wpath = GetWin32Path(old_path);
|
||||
const std::wstring new_wpath = GetWin32Path(new_path);
|
||||
|
||||
if (!MoveFileExW(old_wpath.c_str(), new_wpath.c_str(), MOVEFILE_REPLACE_EXISTING))
|
||||
if (!MoveFileExW(old_wpath.c_str(), new_wpath.c_str(), MOVEFILE_REPLACE_EXISTING)) [[unlikely]]
|
||||
{
|
||||
const DWORD err = GetLastError();
|
||||
Error::SetWin32(error, "MoveFileExW() failed: ", err);
|
||||
Log_ErrorPrintf("MoveFileEx('%s', '%s') failed: %08X", old_path, new_path, err);
|
||||
Error::SetWin32(error, "MoveFileExW() failed: ", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2289,7 +2287,6 @@ bool FileSystem::RenamePath(const char* old_path, const char* new_path, Error* e
|
||||
{
|
||||
const int err = errno;
|
||||
Error::SetErrno(error, "rename() failed: ", err);
|
||||
Log_ErrorPrintf("rename('%s', '%s') failed: %d", old_path, new_path, err);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2410,13 +2407,13 @@ static bool SetLock(int fd, bool lock)
|
||||
const off_t offs = lseek(fd, 0, SEEK_CUR);
|
||||
if (offs < 0)
|
||||
{
|
||||
Log_ErrorPrintf("lseek(%d) failed: %d", fd, errno);
|
||||
Log_ErrorFmt("lseek({}) failed: {}", fd, errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (offs != 0 && lseek(fd, 0, SEEK_SET) < 0)
|
||||
{
|
||||
Log_ErrorPrintf("lseek(%d, 0) failed: %d", fd, errno);
|
||||
Log_ErrorFmt("lseek({}, 0) failed: {}", fd, errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2425,7 +2422,7 @@ static bool SetLock(int fd, bool lock)
|
||||
Panic("Repositioning file descriptor after lock failed.");
|
||||
|
||||
if (!res)
|
||||
Log_ErrorPrintf("lockf() for %s failed: %d", lock ? "lock" : "unlock", errno);
|
||||
Log_ErrorFmt("lockf() for {} failed: {}", lock ? "lock" : "unlock", errno);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -17,11 +17,11 @@ enum LOGLEVEL
|
||||
LOGLEVEL_NONE = 0, // Silences all log traffic
|
||||
LOGLEVEL_ERROR = 1, // "ErrorPrint"
|
||||
LOGLEVEL_WARNING = 2, // "WarningPrint"
|
||||
LOGLEVEL_PERF = 3, // "PerfPrint"
|
||||
LOGLEVEL_PERF = 3, // "PerfPrint" // TODO: Purge
|
||||
LOGLEVEL_INFO = 4, // "InfoPrint"
|
||||
LOGLEVEL_VERBOSE = 5, // "VerbosePrint"
|
||||
LOGLEVEL_DEV = 6, // "DevPrint"
|
||||
LOGLEVEL_PROFILE = 7, // "ProfilePrint"
|
||||
LOGLEVEL_PROFILE = 7, // "ProfilePrint" // TODO: Purge
|
||||
LOGLEVEL_DEBUG = 8, // "DebugPrint"
|
||||
LOGLEVEL_TRACE = 9, // "TracePrint"
|
||||
LOGLEVEL_COUNT = 10
|
||||
|
||||
@ -36,7 +36,7 @@ bool MemMap::MemProtect(void* baseaddr, size_t size, PageProtect mode)
|
||||
DWORD old_protect;
|
||||
if (!VirtualProtect(baseaddr, size, static_cast<DWORD>(mode), &old_protect))
|
||||
{
|
||||
Log_ErrorPrintf("VirtualProtect() failed with error %u", GetLastError());
|
||||
Log_ErrorFmt("VirtualProtect() failed with error {}", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -205,7 +205,7 @@ u8* SharedMemoryMappingArea::Map(void* file_handle, size_t file_offset, void* ma
|
||||
if (!MapViewOfFile3(static_cast<HANDLE>(file_handle), GetCurrentProcess(), map_base, file_offset, map_size,
|
||||
MEM_REPLACE_PLACEHOLDER, PAGE_READWRITE, nullptr, 0))
|
||||
{
|
||||
Log_ErrorPrintf("MapViewOfFile3() failed: %u", GetLastError());
|
||||
Log_ErrorFmt("MapViewOfFile3() failed: {}", GetLastError());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -231,7 +231,7 @@ bool SharedMemoryMappingArea::Unmap(void* map_base, size_t map_size)
|
||||
// unmap the specified range
|
||||
if (!UnmapViewOfFile2(GetCurrentProcess(), map_base, MEM_PRESERVE_PLACEHOLDER))
|
||||
{
|
||||
Log_ErrorPrintf("UnmapViewOfFile2() failed: %u", GetLastError());
|
||||
Log_ErrorFmt("UnmapViewOfFile2() failed: {}", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -285,9 +285,9 @@ bool MemMap::MemProtect(void* baseaddr, size_t size, PageProtect mode)
|
||||
DebugAssertMsg((size & (HOST_PAGE_SIZE - 1)) == 0, "Size is page aligned");
|
||||
|
||||
const int result = mprotect(baseaddr, size, static_cast<int>(mode));
|
||||
if (result != 0)
|
||||
if (result != 0) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("mprotect() for %zu at %p failed", size, baseaddr);
|
||||
Log_ErrorFmt("mprotect() for {} at {} failed", size, baseaddr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user