Logging API change (refactor) (#19324)

* Rename LogType to Log

* Explicitly use the Log:: enum when logging. Allows for autocomplete when editing.

* Mac/ARM64 buildfix

* Do the same with the hle result log macros

* Rename the log names to mixed case while at it.

* iOS buildfix

* Qt buildfix attempt, ARM32 buildfix
This commit is contained in:
Henrik Rydgård
2024-07-14 14:42:59 +02:00
committed by GitHub
parent ae3ff686f0
commit e01ca5b057
393 changed files with 6198 additions and 6193 deletions

View File

@@ -123,7 +123,7 @@ bool DirectoryFileHandle::Open(const Path &basePath, std::string &fileName, File
#if HOST_IS_CASE_SENSITIVE
if (access & (FILEACCESS_APPEND | FILEACCESS_CREATE | FILEACCESS_WRITE)) {
DEBUG_LOG(FILESYS, "Checking case for path %s", fileName.c_str());
DEBUG_LOG(Log::FileSystem, "Checking case for path %s", fileName.c_str());
if (!FixPathCase(basePath, fileName, FPC_PATH_MUST_EXIST)) {
error = SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
return false; // or go on and attempt (for a better error code than just 0?)
@@ -225,7 +225,7 @@ bool DirectoryFileHandle::Open(const Path &basePath, std::string &fileName, File
// Success
return true;
} else {
ERROR_LOG(FILESYS, "File::OpenFD returned an error");
ERROR_LOG(Log::FileSystem, "File::OpenFD returned an error");
// TODO: Need better error codes from OpenFD so we can distinguish
// disk full. Just set not found for now.
error = SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
@@ -262,7 +262,7 @@ bool DirectoryFileHandle::Open(const Path &basePath, std::string &fileName, File
return false;
}
fullName = GetLocalPath(basePath, fileName);
DEBUG_LOG(FILESYS, "Case may have been incorrect, second try opening %s (%s)", fullName.c_str(), fileName.c_str());
DEBUG_LOG(Log::FileSystem, "Case may have been incorrect, second try opening %s (%s)", fullName.c_str(), fileName.c_str());
// And try again with the correct case this time
#ifdef _WIN32
@@ -361,7 +361,7 @@ size_t DirectoryFileHandle::Write(const u8* pointer, s64 size)
MemoryStick_NotifyWrite();
if (diskFull) {
ERROR_LOG(FILESYS, "Disk full");
ERROR_LOG(Log::FileSystem, "Disk full");
auto err = GetI18NCategory(I18NCat::ERRORS);
g_OSD.Show(OSDType::MESSAGE_ERROR, err->T("Disk full while writing data"));
// We only return an error when the disk is actually full.
@@ -419,12 +419,12 @@ void DirectoryFileHandle::Close()
#ifdef _WIN32
Seek((s32)needsTrunc_, FILEMOVE_BEGIN);
if (SetEndOfFile(hFile) == 0) {
ERROR_LOG_REPORT(FILESYS, "Failed to truncate file.");
ERROR_LOG_REPORT(Log::FileSystem, "Failed to truncate file.");
}
#elif !PPSSPP_PLATFORM(SWITCH)
// Note: it's not great that Switch cannot truncate appropriately...
if (ftruncate(hFile, (off_t)needsTrunc_) != 0) {
ERROR_LOG_REPORT(FILESYS, "Failed to truncate file.");
ERROR_LOG_REPORT(Log::FileSystem, "Failed to truncate file.");
}
#endif
}
@@ -439,7 +439,7 @@ void DirectoryFileHandle::Close()
void DirectoryFileSystem::CloseAll() {
for (auto iter = entries.begin(); iter != entries.end(); ++iter) {
INFO_LOG(FILESYS, "DirectoryFileSystem::CloseAll(): Force closing %d (%s)", (int)iter->first, iter->second.guestFilename.c_str());
INFO_LOG(Log::FileSystem, "DirectoryFileSystem::CloseAll(): Force closing %d (%s)", (int)iter->first, iter->second.guestFilename.c_str());
iter->second.hFile.Close();
}
entries.clear();
@@ -577,7 +577,7 @@ int DirectoryFileSystem::OpenFile(std::string filename, FileAccess access, const
logError = (int)errno;
#endif
if (!(access & FILEACCESS_PPSSPP_QUIET)) {
ERROR_LOG(FILESYS, "DirectoryFileSystem::OpenFile('%s'): FAILED, %d - access = %d '%s'", filename.c_str(), logError, (int)(access & FILEACCESS_PSP_FLAGS), errorString.c_str());
ERROR_LOG(Log::FileSystem, "DirectoryFileSystem::OpenFile('%s'): FAILED, %d - access = %d '%s'", filename.c_str(), logError, (int)(access & FILEACCESS_PSP_FLAGS), errorString.c_str());
}
return err;
} else {
@@ -606,7 +606,7 @@ void DirectoryFileSystem::CloseFile(u32 handle) {
entries.erase(iter);
} else {
//This shouldn't happen...
ERROR_LOG(FILESYS,"Cannot close file that hasn't been opened: %08x", handle);
ERROR_LOG(Log::FileSystem,"Cannot close file that hasn't been opened: %08x", handle);
}
}
@@ -632,7 +632,7 @@ size_t DirectoryFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size, int &use
EntryMap::iterator iter = entries.find(handle);
if (iter != entries.end()) {
if (size < 0) {
ERROR_LOG_REPORT(FILESYS, "Invalid read for %lld bytes from disk %s", size, iter->second.guestFilename.c_str());
ERROR_LOG_REPORT(Log::FileSystem, "Invalid read for %lld bytes from disk %s", size, iter->second.guestFilename.c_str());
return 0;
}
@@ -640,7 +640,7 @@ size_t DirectoryFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size, int &use
return bytesRead;
} else {
// This shouldn't happen...
ERROR_LOG(FILESYS,"Cannot read file that hasn't been opened: %08x", handle);
ERROR_LOG(Log::FileSystem,"Cannot read file that hasn't been opened: %08x", handle);
return 0;
}
}
@@ -657,7 +657,7 @@ size_t DirectoryFileSystem::WriteFile(u32 handle, const u8 *pointer, s64 size, i
return bytesWritten;
} else {
//This shouldn't happen...
ERROR_LOG(FILESYS,"Cannot write to file that hasn't been opened: %08x", handle);
ERROR_LOG(Log::FileSystem,"Cannot write to file that hasn't been opened: %08x", handle);
return 0;
}
}
@@ -668,7 +668,7 @@ size_t DirectoryFileSystem::SeekFile(u32 handle, s32 position, FileMove type) {
return iter->second.hFile.Seek(position,type);
} else {
//This shouldn't happen...
ERROR_LOG(FILESYS,"Cannot seek in file that hasn't been opened: %08x", handle);
ERROR_LOG(Log::FileSystem,"Cannot seek in file that hasn't been opened: %08x", handle);
return 0;
}
}
@@ -774,7 +774,7 @@ static std::string SimulateVFATBug(std::string filename) {
}
if (apply_hack) {
VERBOSE_LOG(FILESYS, "Applying VFAT hack to filename: %s", filename.c_str());
VERBOSE_LOG(Log::FileSystem, "Applying VFAT hack to filename: %s", filename.c_str());
// In this situation, NT would write UPPERCASE, and just set a flag to say "actually lowercase".
// That VFAT flag isn't read by the PSP firmware, so let's pretend to "not read it."
std::transform(filename.begin(), filename.end(), filename.begin(), toupper);
@@ -920,13 +920,13 @@ void DirectoryFileSystem::DoState(PointerWrap &p) {
u32 err;
bool brokenFile = false;
if (!entry.hFile.Open(basePath,entry.guestFilename,entry.access, err)) {
ERROR_LOG(FILESYS, "Failed to reopen file while loading state: %s", entry.guestFilename.c_str());
ERROR_LOG(Log::FileSystem, "Failed to reopen file while loading state: %s", entry.guestFilename.c_str());
brokenFile = true;
}
u32 position;
Do(p, position);
if (position != entry.hFile.Seek(position, FILEMOVE_BEGIN)) {
ERROR_LOG(FILESYS, "Failed to restore seek position while loading state: %s", entry.guestFilename.c_str());
ERROR_LOG(Log::FileSystem, "Failed to restore seek position while loading state: %s", entry.guestFilename.c_str());
brokenFile = true;
}
if (s >= 2) {
@@ -990,18 +990,18 @@ bool VFSFileSystem::RemoveFile(const std::string &filename) {
int VFSFileSystem::OpenFile(std::string filename, FileAccess access, const char *devicename) {
if (access != FILEACCESS_READ) {
ERROR_LOG(FILESYS, "VFSFileSystem only supports plain reading");
ERROR_LOG(Log::FileSystem, "VFSFileSystem only supports plain reading");
return SCE_KERNEL_ERROR_ERRNO_INVALID_FLAG;
}
std::string fullName = GetLocalPath(filename);
const char *fullNameC = fullName.c_str();
VERBOSE_LOG(FILESYS, "VFSFileSystem actually opening %s (%s)", fullNameC, filename.c_str());
VERBOSE_LOG(Log::FileSystem, "VFSFileSystem actually opening %s (%s)", fullNameC, filename.c_str());
size_t size;
u8 *data = g_VFS.ReadFile(fullNameC, &size);
if (!data) {
ERROR_LOG(FILESYS, "VFSFileSystem failed to open %s", filename.c_str());
ERROR_LOG(Log::FileSystem, "VFSFileSystem failed to open %s", filename.c_str());
return SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
}
@@ -1040,7 +1040,7 @@ void VFSFileSystem::CloseFile(u32 handle) {
entries.erase(iter);
} else {
//This shouldn't happen...
ERROR_LOG(FILESYS,"Cannot close file that hasn't been opened: %08x", handle);
ERROR_LOG(Log::FileSystem,"Cannot close file that hasn't been opened: %08x", handle);
}
}
@@ -1063,7 +1063,7 @@ size_t VFSFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size) {
}
size_t VFSFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size, int &usec) {
DEBUG_LOG(FILESYS,"VFSFileSystem::ReadFile %08x %p %i", handle, pointer, (u32)size);
DEBUG_LOG(Log::FileSystem,"VFSFileSystem::ReadFile %08x %p %i", handle, pointer, (u32)size);
EntryMap::iterator iter = entries.find(handle);
if (iter != entries.end())
{
@@ -1075,7 +1075,7 @@ size_t VFSFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size, int &usec) {
iter->second.seekPos += size;
return bytesRead;
} else {
ERROR_LOG(FILESYS,"Cannot read file that hasn't been opened: %08x", handle);
ERROR_LOG(Log::FileSystem,"Cannot read file that hasn't been opened: %08x", handle);
return 0;
}
}
@@ -1101,7 +1101,7 @@ size_t VFSFileSystem::SeekFile(u32 handle, s32 position, FileMove type) {
return iter->second.seekPos;
} else {
//This shouldn't happen...
ERROR_LOG(FILESYS,"Cannot seek in file that hasn't been opened: %08x", handle);
ERROR_LOG(Log::FileSystem,"Cannot seek in file that hasn't been opened: %08x", handle);
return 0;
}
}
@@ -1125,6 +1125,6 @@ void VFSFileSystem::DoState(PointerWrap &p) {
if (num != 0) {
p.SetError(p.ERROR_WARNING);
ERROR_LOG(FILESYS, "FIXME: Open files during savestate, could go badly.");
ERROR_LOG(Log::FileSystem, "FIXME: Open files during savestate, could go badly.");
}
}