diff --git a/Common/File/AndroidContentURI.cpp b/Common/File/AndroidContentURI.cpp index 1bcd7f48b3..db5808ea58 100644 --- a/Common/File/AndroidContentURI.cpp +++ b/Common/File/AndroidContentURI.cpp @@ -48,7 +48,7 @@ bool AndroidContentURI::Parse(std::string_view path) { AndroidContentURI AndroidContentURI::WithRootFilePath(const std::string &filePath) { if (root.empty()) { - ERROR_LOG(Log::System, "WithRootFilePath cannot be used with single file URIs."); + ERROR_LOG(Log::IO, "WithRootFilePath cannot be used with single file URIs."); return *this; } @@ -116,7 +116,7 @@ bool AndroidContentURI::ComputePathTo(const AndroidContentURI &other, std::strin size_t offset = FilePath().size() + 1; const auto &otherFilePath = other.FilePath(); if (offset >= otherFilePath.size()) { - ERROR_LOG(Log::System, "Bad call to PathTo. '%s' -> '%s'", FilePath().c_str(), other.FilePath().c_str()); + ERROR_LOG(Log::IO, "Bad call to PathTo. '%s' -> '%s'", FilePath().c_str(), other.FilePath().c_str()); return false; } diff --git a/Common/File/AndroidStorage.cpp b/Common/File/AndroidStorage.cpp index 5d295a31ce..681639234e 100644 --- a/Common/File/AndroidStorage.cpp +++ b/Common/File/AndroidStorage.cpp @@ -250,7 +250,7 @@ std::vector Android_ListContentUri(const std::string &uri, const } else if (ParseFileInfo(line, &info)) { // We can just reconstruct the URI. info.fullName = Path(uri) / info.name; - // INFO_LOG(Log::FileSystem, "%s", info.name.c_str()); + // INFO_LOG(Log::IO, "%s", info.name.c_str()); items.push_back(info); } } @@ -262,7 +262,7 @@ std::vector Android_ListContentUri(const std::string &uri, const double elapsed = time_now_d() - start; double threshold = 0.1; if (elapsed >= threshold) { - INFO_LOG(Log::FileSystem, "Listing directory on content URI '%s' took %0.3f s (%d files, log threshold = %0.3f)", uri.c_str(), elapsed, (int)items.size(), threshold); + INFO_LOG(Log::IO, "Listing directory on content URI '%s' took %0.3f s (%d files, log threshold = %0.3f)", uri.c_str(), elapsed, (int)items.size(), threshold); } return items; } diff --git a/Common/File/DirListing.cpp b/Common/File/DirListing.cpp index e6140f1052..8ada1dffa0 100644 --- a/Common/File/DirListing.cpp +++ b/Common/File/DirListing.cpp @@ -63,7 +63,7 @@ static uint64_t FiletimeToStatTime(FILETIME ft) { bool GetFileInfo(const Path &path, FileInfo * fileInfo) { if (LOG_IO) { - INFO_LOG(Log::System, "GetFileInfo %s", path.ToVisualString().c_str()); + INFO_LOG(Log::IO, "GetFileInfo %s", path.ToVisualString().c_str()); } if (SIMULATE_SLOW_IO) { sleep_ms(300, "slow-io-sim"); @@ -205,7 +205,7 @@ std::vector ApplyFilter(std::vector files, const bool GetFilesInDir(const Path &directory, std::vector *files, const char *filter, int flags, std::string_view prefix) { if (LOG_IO) { - INFO_LOG(Log::System, "GetFilesInDir '%s' (ext %s, prefix %.*s)", directory.ToVisualString().c_str(), filter, (int)prefix.size(), prefix.data()); + INFO_LOG(Log::IO, "GetFilesInDir '%s' (ext %s, prefix %.*s)", directory.ToVisualString().c_str(), filter, (int)prefix.size(), prefix.data()); } if (SIMULATE_SLOW_IO) { sleep_ms(300, "slow-io-sim"); @@ -218,7 +218,7 @@ bool GetFilesInDir(const Path &directory, std::vector *files, const ch int beforeFilter = (int)fileList.size(); *files = ApplyFilter(fileList, filter, prefix); std::sort(files->begin(), files->end()); - DEBUG_LOG(Log::System, "GetFilesInDir: Found %d entries (%d before filter)", (int)files->size(), beforeFilter); + DEBUG_LOG(Log::IO, "GetFilesInDir: Found %d entries (%d before filter)", (int)files->size(), beforeFilter); return exists; } @@ -292,7 +292,7 @@ bool GetFilesInDir(const Path &directory, std::vector *files, const ch } if (LOG_IO) { - // INFO_LOG(Log::System, "GetFilesInDir item %s", virtualName.c_str()); + // INFO_LOG(Log::IO, "GetFilesInDir item %s", virtualName.c_str()); } FileInfo info; @@ -369,7 +369,7 @@ bool GetFilesInDir(const Path &directory, std::vector *files, const ch #endif std::sort(files->begin(), files->end()); if (LOG_IO) { - INFO_LOG(Log::System, "GetFilesInDir: Found %d files", (int)files->size()); + INFO_LOG(Log::IO, "GetFilesInDir: Found %d files", (int)files->size()); } return true; } diff --git a/Common/File/FileUtil.cpp b/Common/File/FileUtil.cpp index 8ce0956b17..e54c974684 100644 --- a/Common/File/FileUtil.cpp +++ b/Common/File/FileUtil.cpp @@ -113,7 +113,7 @@ namespace File { FILE *OpenCFile(const Path &path, const char *mode) { if (LOG_IO) { - INFO_LOG(Log::System, "OpenCFile %s, %s", path.c_str(), mode); + INFO_LOG(Log::IO, "OpenCFile %s, %s", path.c_str(), mode); } if (SIMULATE_SLOW_IO) { sleep_ms(300, "slow-io-sim"); @@ -124,7 +124,7 @@ FILE *OpenCFile(const Path &path, const char *mode) { case PathType::CONTENT_URI: // We're gonna need some error codes.. if (!strcmp(mode, "r") || !strcmp(mode, "rb") || !strcmp(mode, "rt")) { - INFO_LOG(Log::Common, "Opening content file for read: '%s'", path.c_str()); + INFO_LOG(Log::IO, "Opening content file for read: '%s'", path.c_str()); // Read, let's support this - easy one. int descriptor = Android_OpenContentUriFd(path.ToString(), Android_OpenContentUriMode::READ); if (descriptor < 0) { @@ -135,20 +135,20 @@ FILE *OpenCFile(const Path &path, const char *mode) { // Need to be able to create the file here if it doesn't exist. // Not exactly sure which abstractions are best, let's start simple. if (!File::Exists(path)) { - INFO_LOG(Log::Common, "OpenCFile(%s): Opening content file for write. Doesn't exist, creating empty and reopening.", path.c_str()); + INFO_LOG(Log::IO, "OpenCFile(%s): Opening content file for write. Doesn't exist, creating empty and reopening.", path.c_str()); std::string name = path.GetFilename(); if (path.CanNavigateUp()) { Path parent = path.NavigateUp(); if (Android_CreateFile(parent.ToString(), name) != StorageError::SUCCESS) { - WARN_LOG(Log::Common, "Failed to create file '%s' in '%s'", name.c_str(), parent.c_str()); + WARN_LOG(Log::IO, "Failed to create file '%s' in '%s'", name.c_str(), parent.c_str()); return nullptr; } } else { - INFO_LOG_REPORT_ONCE(openCFileFailedNavigateUp, Log::Common, "Failed to navigate up to create file: %s", path.c_str()); + INFO_LOG_REPORT_ONCE(openCFileFailedNavigateUp, Log::IO, "Failed to navigate up to create file: %s", path.c_str()); return nullptr; } } else { - INFO_LOG(Log::Common, "OpenCFile(%s): Opening existing content file for write (truncating). Requested mode: '%s'", path.c_str(), mode); + INFO_LOG(Log::IO, "OpenCFile(%s): Opening existing content file for write (truncating). Requested mode: '%s'", path.c_str(), mode); } // TODO: Support append modes and stuff... For now let's go with the most common one. @@ -160,7 +160,7 @@ FILE *OpenCFile(const Path &path, const char *mode) { } int descriptor = Android_OpenContentUriFd(path.ToString(), openMode); if (descriptor < 0) { - INFO_LOG(Log::Common, "Opening '%s' for write failed", path.ToString().c_str()); + INFO_LOG(Log::IO, "Opening '%s' for write failed", path.ToString().c_str()); return nullptr; } FILE *f = fdopen(descriptor, fmode); @@ -170,12 +170,12 @@ FILE *OpenCFile(const Path &path, const char *mode) { } return f; } else { - ERROR_LOG(Log::Common, "OpenCFile(%s): Mode not yet supported: %s", path.c_str(), mode); + ERROR_LOG(Log::IO, "OpenCFile(%s): Mode not yet supported: %s", path.c_str(), mode); return nullptr; } break; default: - ERROR_LOG(Log::Common, "OpenCFile(%s): PathType not yet supported", path.c_str()); + ERROR_LOG(Log::IO, "OpenCFile(%s): PathType not yet supported", path.c_str()); return nullptr; } @@ -217,7 +217,7 @@ static std::string OpenFlagToString(OpenFlag flags) { int OpenFD(const Path &path, OpenFlag flags) { if (LOG_IO) { - INFO_LOG(Log::System, "OpenFD %s, %d", path.c_str(), flags); + INFO_LOG(Log::IO, "OpenFD %s, %d", path.c_str(), flags); } if (SIMULATE_SLOW_IO) { sleep_ms(300, "slow-io-sim"); @@ -227,27 +227,27 @@ int OpenFD(const Path &path, OpenFlag flags) { case PathType::CONTENT_URI: break; default: - ERROR_LOG(Log::Common, "OpenFD: Only supports Content URI paths. Not '%s' (%s)!", path.c_str(), OpenFlagToString(flags).c_str()); + ERROR_LOG(Log::IO, "OpenFD: Only supports Content URI paths. Not '%s' (%s)!", path.c_str(), OpenFlagToString(flags).c_str()); // Not yet supported - use other paths. return -1; } if (flags & OPEN_CREATE) { if (!File::Exists(path)) { - INFO_LOG(Log::Common, "OpenFD(%s): Creating file.", path.c_str()); + INFO_LOG(Log::IO, "OpenFD(%s): Creating file.", path.c_str()); std::string name = path.GetFilename(); if (path.CanNavigateUp()) { Path parent = path.NavigateUp(); if (Android_CreateFile(parent.ToString(), name) != StorageError::SUCCESS) { - WARN_LOG(Log::Common, "OpenFD: Failed to create file '%s' in '%s'", name.c_str(), parent.c_str()); + WARN_LOG(Log::IO, "OpenFD: Failed to create file '%s' in '%s'", name.c_str(), parent.c_str()); return -1; } } else { - INFO_LOG(Log::Common, "Failed to navigate up to create file: %s", path.c_str()); + INFO_LOG(Log::IO, "Failed to navigate up to create file: %s", path.c_str()); return -1; } } else { - INFO_LOG(Log::Common, "OpenCFile(%s): Opening existing content file ('%s')", path.c_str(), OpenFlagToString(flags).c_str()); + INFO_LOG(Log::IO, "OpenCFile(%s): Opening existing content file ('%s')", path.c_str(), OpenFlagToString(flags).c_str()); } } @@ -263,14 +263,14 @@ int OpenFD(const Path &path, OpenFlag flags) { // TODO: Maybe better checking of additional flags here. } else { // TODO: Add support for more modes if possible. - ERROR_LOG_REPORT_ONCE(openFlagNotSupported, Log::Common, "OpenFlag %s not yet supported", OpenFlagToString(flags).c_str()); + ERROR_LOG_REPORT_ONCE(openFlagNotSupported, Log::IO, "OpenFlag %s not yet supported", OpenFlagToString(flags).c_str()); return -1; } - INFO_LOG(Log::Common, "Android_OpenContentUriFd: %s (%s)", path.c_str(), OpenFlagToString(flags).c_str()); + INFO_LOG(Log::IO, "Android_OpenContentUriFd: %s (%s)", path.c_str(), OpenFlagToString(flags).c_str()); int descriptor = Android_OpenContentUriFd(path.ToString(), mode); if (descriptor < 0) { - ERROR_LOG(Log::Common, "Android_OpenContentUriFd failed: '%s'", path.c_str()); + ERROR_LOG(Log::IO, "Android_OpenContentUriFd failed: '%s'", path.c_str()); } if (flags & OPEN_APPEND) { @@ -324,7 +324,7 @@ static bool ResolvePathVista(const std::wstring &path, wchar_t *buf, DWORD bufSi std::string ResolvePath(std::string_view path) { if (LOG_IO) { - INFO_LOG(Log::System, "ResolvePath %.*s", (int)path.size(), path.data()); + INFO_LOG(Log::IO, "ResolvePath %.*s", (int)path.size(), path.data()); } if (SIMULATE_SLOW_IO) { sleep_ms(100, "slow-io-sim"); @@ -420,7 +420,7 @@ bool ExistsInDir(const Path &path, const std::string &filename) { bool Exists(const Path &path) { if (LOG_IO) { - INFO_LOG(Log::System, "Exists %s", path.ToVisualString().c_str()); + INFO_LOG(Log::IO, "Exists %s", path.ToVisualString().c_str()); } if (SIMULATE_SLOW_IO) { sleep_ms(200, "slow-io-sim"); @@ -459,7 +459,7 @@ bool Exists(const Path &path) { // Returns true if filename exists and is a directory bool IsDirectory(const Path &path) { if (LOG_IO) { - INFO_LOG(Log::System, "IsDirectory %s", path.c_str()); + INFO_LOG(Log::IO, "IsDirectory %s", path.c_str()); } if (SIMULATE_SLOW_IO) { sleep_ms(100, "slow-io-sim"); @@ -489,7 +489,7 @@ bool IsDirectory(const Path &path) { #endif auto err = GetLastError(); if (err != ERROR_FILE_NOT_FOUND) { - WARN_LOG(Log::Common, "GetFileAttributes failed on %s: %08x %s", path.ToVisualString().c_str(), (uint32_t)err, GetStringErrorMsg(err).c_str()); + WARN_LOG(Log::IO, "GetFileAttributes failed on %s: %08x %s", path.ToVisualString().c_str(), (uint32_t)err, GetStringErrorMsg(err).c_str()); } return false; } @@ -500,7 +500,7 @@ bool IsDirectory(const Path &path) { struct stat file_info{}; int result = stat(copy.c_str(), &file_info); if (result < 0) { - WARN_LOG(Log::Common, "IsDirectory: stat failed on %s: %s", copy.c_str(), GetLastErrorMsg().c_str()); + WARN_LOG(Log::IO, "IsDirectory: stat failed on %s: %s", copy.c_str(), GetLastErrorMsg().c_str()); return false; } return S_ISDIR(file_info.st_mode); @@ -525,37 +525,37 @@ bool Delete(const Path &filename) { // Return true because we care about the file no // being there, not the actual delete. if (!Exists(filename)) { - WARN_LOG(Log::Common, "Delete: '%s' already does not exist", filename.c_str()); + WARN_LOG(Log::IO, "Delete: '%s' already does not exist", filename.c_str()); return true; } // We can't delete a directory if (IsDirectory(filename)) { - WARN_LOG(Log::Common, "Delete failed: '%s' is a directory", filename.c_str()); + WARN_LOG(Log::IO, "Delete failed: '%s' is a directory", filename.c_str()); return false; } #ifdef _WIN32 #if PPSSPP_PLATFORM(UWP) if (!DeleteFileFromAppW(filename.ToWString().c_str())) { - WARN_LOG(Log::Common, "Delete: DeleteFile failed on %s: %s", filename.c_str(), GetLastErrorMsg().c_str()); + WARN_LOG(Log::IO, "Delete: DeleteFile failed on %s: %s", filename.c_str(), GetLastErrorMsg().c_str()); return false; } #else if (!DeleteFile(filename.ToWString().c_str())) { - WARN_LOG(Log::Common, "Delete: DeleteFile failed on %s: %s", filename.c_str(), GetLastErrorMsg().c_str()); + WARN_LOG(Log::IO, "Delete: DeleteFile failed on %s: %s", filename.c_str(), GetLastErrorMsg().c_str()); return false; } #endif #else if (unlink(filename.c_str()) == -1) { - WARN_LOG(Log::Common, "Delete: unlink failed on %s: %s", + WARN_LOG(Log::IO, "Delete: unlink failed on %s: %s", filename.c_str(), GetLastErrorMsg().c_str()); return false; } #endif - INFO_LOG(Log::Common, "Delete: file %s was deleted.", filename.c_str()); + INFO_LOG(Log::IO, "Delete: file %s was deleted.", filename.c_str()); return true; } @@ -563,7 +563,7 @@ bool Delete(const Path &filename) { bool CreateDir(const Path &path) { if (SIMULATE_SLOW_IO) { sleep_ms(100, "slow-io-sim"); - INFO_LOG(Log::System, "CreateDir %s", path.c_str()); + INFO_LOG(Log::IO, "CreateDir %s", path.c_str()); } switch (path.Type()) { case PathType::NATIVE: @@ -581,11 +581,11 @@ bool CreateDir(const Path &path) { AndroidContentURI uri(path.ToString()); std::string newDirName = uri.GetLastPart(); if (uri.NavigateUp()) { - INFO_LOG(Log::Common, "Calling Android_CreateDirectory(%s, %s)", uri.ToString().c_str(), newDirName.c_str()); + INFO_LOG(Log::IO, "Calling Android_CreateDirectory(%s, %s)", uri.ToString().c_str(), newDirName.c_str()); return Android_CreateDirectory(uri.ToString(), newDirName) == StorageError::SUCCESS; } else { // Bad path - can't create this directory. - WARN_LOG(Log::Common, "CreateDir failed: '%s'", path.c_str()); + WARN_LOG(Log::IO, "CreateDir failed: '%s'", path.c_str()); return false; } break; @@ -594,7 +594,7 @@ bool CreateDir(const Path &path) { return false; } - DEBUG_LOG(Log::Common, "CreateDir('%s')", path.c_str()); + DEBUG_LOG(Log::IO, "CreateDir('%s')", path.c_str()); #ifdef _WIN32 #if PPSSPP_PLATFORM(UWP) if (CreateDirectoryFromAppW(path.ToWString().c_str(), NULL)) @@ -606,10 +606,10 @@ bool CreateDir(const Path &path) { DWORD error = GetLastError(); if (error == ERROR_ALREADY_EXISTS) { - DEBUG_LOG(Log::Common, "CreateDir: CreateDirectory failed on %s: already exists", path.c_str()); + DEBUG_LOG(Log::IO, "CreateDir: CreateDirectory failed on %s: already exists", path.c_str()); return true; } - ERROR_LOG(Log::Common, "CreateDir: CreateDirectory failed on %s: %08x %s", path.c_str(), (uint32_t)error, GetStringErrorMsg(error).c_str()); + ERROR_LOG(Log::IO, "CreateDir: CreateDirectory failed on %s: %08x %s", path.c_str(), (uint32_t)error, GetStringErrorMsg(error).c_str()); return false; #else if (mkdir(path.ToString().c_str(), 0755) == 0) { @@ -618,11 +618,11 @@ bool CreateDir(const Path &path) { int err = errno; if (err == EEXIST) { - DEBUG_LOG(Log::Common, "CreateDir: mkdir failed on %s: already exists", path.c_str()); + DEBUG_LOG(Log::IO, "CreateDir: mkdir failed on %s: already exists", path.c_str()); return true; } - ERROR_LOG(Log::Common, "CreateDir: mkdir failed on %s: %s", path.c_str(), strerror(err)); + ERROR_LOG(Log::IO, "CreateDir: mkdir failed on %s: %s", path.c_str(), strerror(err)); return false; #endif } @@ -630,7 +630,7 @@ bool CreateDir(const Path &path) { // Creates the full path of fullPath returns true on success bool CreateFullPath(const Path &path) { if (File::Exists(path)) { - DEBUG_LOG(Log::Common, "CreateFullPath: path exists %s", path.ToVisualString().c_str()); + DEBUG_LOG(Log::IO, "CreateFullPath: path exists %s", path.ToVisualString().c_str()); return true; } @@ -639,7 +639,7 @@ bool CreateFullPath(const Path &path) { case PathType::CONTENT_URI: break; // OK default: - ERROR_LOG(Log::Common, "CreateFullPath(%s): Not yet supported", path.ToVisualString().c_str()); + ERROR_LOG(Log::IO, "CreateFullPath(%s): Not yet supported", path.ToVisualString().c_str()); return false; } @@ -657,7 +657,7 @@ bool CreateFullPath(const Path &path) { // Probably not necessary sanity check, ported from the old code. if (parts.size() > 100) { - ERROR_LOG(Log::Common, "CreateFullPath: directory structure too deep"); + ERROR_LOG(Log::IO, "CreateFullPath: directory structure too deep"); return false; } @@ -673,7 +673,7 @@ bool CreateFullPath(const Path &path) { // renames file srcFilename to destFilename, returns true on success bool Rename(const Path &srcFilename, const Path &destFilename) { if (LOG_IO) { - INFO_LOG(Log::System, "Rename %s -> %s", srcFilename.c_str(), destFilename.c_str()); + INFO_LOG(Log::IO, "Rename %s -> %s", srcFilename.c_str(), destFilename.c_str()); } if (SIMULATE_SLOW_IO) { sleep_ms(100, "slow-io-sim"); @@ -694,16 +694,16 @@ bool Rename(const Path &srcFilename, const Path &destFilename) { // Content URI: Can only rename if in the same folder. // TODO: Fallback to move + rename? Or do we even care about that use case? We have MoveIfFast for such tricks. if (srcFilename.GetDirectory() != destFilename.GetDirectory()) { - INFO_LOG(Log::Common, "Content URI rename: Directories not matching, failing. %s --> %s", srcFilename.c_str(), destFilename.c_str()); + INFO_LOG(Log::IO, "Content URI rename: Directories not matching, failing. %s --> %s", srcFilename.c_str(), destFilename.c_str()); return false; } - INFO_LOG(Log::Common, "Content URI rename: %s --> %s", srcFilename.c_str(), destFilename.c_str()); + INFO_LOG(Log::IO, "Content URI rename: %s --> %s", srcFilename.c_str(), destFilename.c_str()); return Android_RenameFileTo(srcFilename.ToString(), destFilename.GetFilename()) == StorageError::SUCCESS; default: return false; } - INFO_LOG(Log::Common, "Rename: %s --> %s", srcFilename.c_str(), destFilename.c_str()); + INFO_LOG(Log::IO, "Rename: %s --> %s", srcFilename.c_str(), destFilename.c_str()); #if defined(_WIN32) && defined(UNICODE) #if PPSSPP_PLATFORM(UWP) @@ -720,7 +720,7 @@ bool Rename(const Path &srcFilename, const Path &destFilename) { return true; #endif - ERROR_LOG(Log::Common, "Rename: failed %s --> %s: %s", + ERROR_LOG(Log::IO, "Rename: failed %s --> %s: %s", srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg().c_str()); return false; } @@ -728,7 +728,7 @@ bool Rename(const Path &srcFilename, const Path &destFilename) { // copies file srcFilename to destFilename, returns true on success bool Copy(const Path &srcFilename, const Path &destFilename) { if (LOG_IO) { - INFO_LOG(Log::System, "Copy %s -> %s", srcFilename.c_str(), destFilename.c_str()); + INFO_LOG(Log::IO, "Copy %s -> %s", srcFilename.c_str(), destFilename.c_str()); } if (SIMULATE_SLOW_IO) { sleep_ms(100, "slow-io-sim"); @@ -743,7 +743,7 @@ bool Copy(const Path &srcFilename, const Path &destFilename) { if (Android_CopyFile(srcFilename.ToString(), destParent.ToString()) == StorageError::SUCCESS) { return true; } - INFO_LOG(Log::Common, "Android_CopyFile failed, falling back."); + INFO_LOG(Log::IO, "Android_CopyFile failed, falling back."); // Else fall through, and try using file I/O. } break; @@ -751,7 +751,7 @@ bool Copy(const Path &srcFilename, const Path &destFilename) { return false; } - INFO_LOG(Log::Common, "Copy by OpenCFile: %s --> %s", srcFilename.c_str(), destFilename.c_str()); + INFO_LOG(Log::IO, "Copy by OpenCFile: %s --> %s", srcFilename.c_str(), destFilename.c_str()); #ifdef _WIN32 #if PPSSPP_PLATFORM(UWP) if (CopyFileFromAppW(srcFilename.ToWString().c_str(), destFilename.ToWString().c_str(), FALSE)) @@ -760,7 +760,7 @@ bool Copy(const Path &srcFilename, const Path &destFilename) { if (CopyFile(srcFilename.ToWString().c_str(), destFilename.ToWString().c_str(), FALSE)) return true; #endif - ERROR_LOG(Log::Common, "Copy: failed %s --> %s: %s", + ERROR_LOG(Log::IO, "Copy: failed %s --> %s: %s", srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg().c_str()); return false; #else // Non-Win32 @@ -773,7 +773,7 @@ bool Copy(const Path &srcFilename, const Path &destFilename) { // Open input file FILE *input = OpenCFile(srcFilename, "rb"); if (!input) { - ERROR_LOG(Log::Common, "Copy: input failed %s --> %s: %s", + ERROR_LOG(Log::IO, "Copy: input failed %s --> %s: %s", srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg().c_str()); return false; } @@ -782,7 +782,7 @@ bool Copy(const Path &srcFilename, const Path &destFilename) { FILE *output = OpenCFile(destFilename, "wb"); if (!output) { fclose(input); - ERROR_LOG(Log::Common, "Copy: output failed %s --> %s: %s", + ERROR_LOG(Log::IO, "Copy: output failed %s --> %s: %s", srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg().c_str()); return false; } @@ -795,7 +795,7 @@ bool Copy(const Path &srcFilename, const Path &destFilename) { int rnum = fread(buffer, sizeof(char), BSIZE, input); if (rnum != BSIZE) { if (ferror(input) != 0) { - ERROR_LOG(Log::Common, + ERROR_LOG(Log::IO, "Copy: failed reading from source, %s --> %s: %s", srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg().c_str()); fclose(input); @@ -807,7 +807,7 @@ bool Copy(const Path &srcFilename, const Path &destFilename) { // write output int wnum = fwrite(buffer, sizeof(char), rnum, output); if (wnum != rnum) { - ERROR_LOG(Log::Common, + ERROR_LOG(Log::IO, "Copy: failed writing to output, %s --> %s: %s", srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg().c_str()); fclose(input); @@ -819,7 +819,7 @@ bool Copy(const Path &srcFilename, const Path &destFilename) { } if (bytesWritten == 0) { - WARN_LOG(Log::Common, "Copy: No bytes written (must mean that input was empty)"); + WARN_LOG(Log::IO, "Copy: No bytes written (must mean that input was empty)"); } // close flushes @@ -833,7 +833,7 @@ bool Copy(const Path &srcFilename, const Path &destFilename) { bool Move(const Path &srcFilename, const Path &destFilename) { if (SIMULATE_SLOW_IO) { sleep_ms(100, "slow-io-sim"); - INFO_LOG(Log::System, "Move %s -> %s", srcFilename.c_str(), destFilename.c_str()); + INFO_LOG(Log::IO, "Move %s -> %s", srcFilename.c_str(), destFilename.c_str()); } bool fast = MoveIfFast(srcFilename, destFilename); if (fast) { @@ -874,7 +874,7 @@ bool MoveIfFast(const Path &srcFilename, const Path &destFilename) { // TODO: Add a way to return an error. uint64_t GetFileSize(const Path &filename) { if (LOG_IO) { - INFO_LOG(Log::System, "GetFileSize %s", filename.c_str()); + INFO_LOG(Log::IO, "GetFileSize %s", filename.c_str()); } if (SIMULATE_SLOW_IO) { sleep_ms(100, "slow-io-sim"); @@ -916,14 +916,14 @@ uint64_t GetFileSize(const Path &filename) { int result = stat64(filename.c_str(), &file_info); #endif if (result != 0) { - WARN_LOG(Log::Common, "GetSize: failed %s: No such file", filename.ToVisualString().c_str()); + WARN_LOG(Log::IO, "GetSize: failed %s: No such file", filename.ToVisualString().c_str()); return 0; } if (S_ISDIR(file_info.st_mode)) { - WARN_LOG(Log::Common, "GetSize: failed %s: is a directory", filename.ToVisualString().c_str()); + WARN_LOG(Log::IO, "GetSize: failed %s: is a directory", filename.ToVisualString().c_str()); return 0; } - DEBUG_LOG(Log::Common, "GetSize: %s: %lld", filename.ToVisualString().c_str(), (long long)file_info.st_size); + DEBUG_LOG(Log::IO, "GetSize: %s: %lld", filename.ToVisualString().c_str(), (long long)file_info.st_size); return file_info.st_size; #endif } @@ -972,10 +972,10 @@ uint64_t GetFileSize(FILE *f) { // creates an empty file filename, returns true on success bool CreateEmptyFile(const Path &filename) { - INFO_LOG(Log::Common, "CreateEmptyFile: %s", filename.c_str()); + INFO_LOG(Log::IO, "CreateEmptyFile: %s", filename.c_str()); FILE *pFile = OpenCFile(filename, "wb"); if (!pFile) { - ERROR_LOG(Log::Common, "CreateEmptyFile: failed to create '%s': %s", filename.c_str(), GetLastErrorMsg().c_str()); + ERROR_LOG(Log::IO, "CreateEmptyFile: failed to create '%s': %s", filename.c_str(), GetLastErrorMsg().c_str()); return false; } fclose(pFile); @@ -986,7 +986,7 @@ bool CreateEmptyFile(const Path &filename) { // WARNING: On Android with content URIs, it will delete recursively! bool DeleteDir(const Path &path) { if (LOG_IO) { - INFO_LOG(Log::System, "DeleteDir %s", path.c_str()); + INFO_LOG(Log::IO, "DeleteDir %s", path.c_str()); } if (SIMULATE_SLOW_IO) { sleep_ms(100, "slow-io-sim"); @@ -999,11 +999,11 @@ bool DeleteDir(const Path &path) { default: return false; } - INFO_LOG(Log::Common, "DeleteDir: directory %s", path.c_str()); + INFO_LOG(Log::IO, "DeleteDir: directory %s", path.c_str()); // check if a directory if (!File::IsDirectory(path)) { - ERROR_LOG(Log::Common, "DeleteDir: Not a directory %s", path.c_str()); + ERROR_LOG(Log::IO, "DeleteDir: Not a directory %s", path.c_str()); return false; } @@ -1019,7 +1019,7 @@ bool DeleteDir(const Path &path) { if (rmdir(path.c_str()) == 0) return true; #endif - ERROR_LOG(Log::Common, "DeleteDir: %s: %s", path.c_str(), GetLastErrorMsg().c_str()); + ERROR_LOG(Log::IO, "DeleteDir: %s: %s", path.c_str(), GetLastErrorMsg().c_str()); return false; } @@ -1033,7 +1033,7 @@ bool DeleteDirRecursively(const Path &path) { // We make use of the dangerous auto-recursive property of Android_RemoveFile. return Android_RemoveFile(path.ToString()) == StorageError::SUCCESS; default: - ERROR_LOG(Log::Common, "DeleteDirRecursively: Path type not supported"); + ERROR_LOG(Log::IO, "DeleteDirRecursively: Path type not supported"); return false; } @@ -1054,7 +1054,7 @@ bool OpenFileInEditor(const Path &fileName) { case PathType::NATIVE: break; // OK default: - ERROR_LOG(Log::Common, "OpenFileInEditor(%s): Path type not supported", fileName.c_str()); + ERROR_LOG(Log::IO, "OpenFileInEditor(%s): Path type not supported", fileName.c_str()); return false; } @@ -1075,7 +1075,7 @@ bool OpenFileInEditor(const Path &fileName) { NOTICE_LOG(Log::Boot, "Launching %s", iniFile.c_str()); int retval = system(iniFile.c_str()); if (retval != 0) { - ERROR_LOG(Log::Common, "Failed to launch ini file"); + ERROR_LOG(Log::IO, "Failed to launch ini file"); } #endif return true; @@ -1353,12 +1353,12 @@ void ChangeMTime(const Path &path, time_t mtime) { } bool IsProbablyInDownloadsFolder(const Path &filename) { - INFO_LOG(Log::Common, "IsProbablyInDownloadsFolder: Looking at %s (%s)...", filename.c_str(), filename.ToVisualString().c_str()); + INFO_LOG(Log::IO, "IsProbablyInDownloadsFolder: Looking at %s (%s)...", filename.c_str(), filename.ToVisualString().c_str()); switch (filename.Type()) { case PathType::CONTENT_URI: { AndroidContentURI uri(filename.ToString()); - INFO_LOG(Log::Common, "Content URI provider: %s", uri.Provider().c_str()); + INFO_LOG(Log::IO, "Content URI provider: %s", uri.Provider().c_str()); if (containsNoCase(uri.Provider(), "download")) { // like com.android.providers.downloads.documents return true; diff --git a/Common/File/PathBrowser.cpp b/Common/File/PathBrowser.cpp index 8a4d71c11d..bfef052d2f 100644 --- a/Common/File/PathBrowser.cpp +++ b/Common/File/PathBrowser.cpp @@ -129,7 +129,7 @@ void PathBrowser::SetPath(const Path &path) { } void PathBrowser::RestrictToRoot(const Path &root) { - INFO_LOG(Log::System, "Restricting to root: %s", root.c_str()); + INFO_LOG(Log::IO, "Restricting to root: %s", root.c_str()); restrictedRoot_ = root; } @@ -244,7 +244,7 @@ bool PathBrowser::GetListing(std::vector &fileInfo, const char * void PathBrowser::ApplyRestriction() { if (!path_.StartsWith(restrictedRoot_) && !startsWith(path_.ToString(), "!")) { - WARN_LOG(Log::System, "Applying path restriction: %s (%s didn't match)", restrictedRoot_.c_str(), path_.c_str()); + WARN_LOG(Log::IO, "Applying path restriction: %s (%s didn't match)", restrictedRoot_.c_str(), path_.c_str()); path_ = restrictedRoot_; } } diff --git a/Common/File/VFS/ZipFileReader.cpp b/Common/File/VFS/ZipFileReader.cpp index 780dbff368..f3f604bb3f 100644 --- a/Common/File/VFS/ZipFileReader.cpp +++ b/Common/File/VFS/ZipFileReader.cpp @@ -111,7 +111,7 @@ bool ZipFileReader::GetFileListing(const char *orig_path, std::vectorclear(); - // INFO_LOG(Log::System, "Zip: Listing '%s'", orig_path); + // INFO_LOG(Log::IO, "Zip: Listing '%s'", orig_path); const std::string relativePath = path.substr(inZipPath_.size()); @@ -125,7 +125,7 @@ bool ZipFileReader::GetFileListing(const char *orig_path, std::vectorpush_back(info); } @@ -142,7 +142,7 @@ bool ZipFileReader::GetFileListing(const char *orig_path, std::vectorpush_back(info); } diff --git a/Common/Log.h b/Common/Log.h index 3f84897129..54c9a84fd1 100644 --- a/Common/Log.h +++ b/Common/Log.h @@ -52,6 +52,7 @@ enum class Log { Printf, TexReplacement, GeDebugger, + UI, sceAudio, sceCtrl, diff --git a/Common/Log/LogManager.cpp b/Common/Log/LogManager.cpp index 4c0d5a3162..e6cc564299 100644 --- a/Common/Log/LogManager.cpp +++ b/Common/Log/LogManager.cpp @@ -91,6 +91,7 @@ static const char * const g_logTypeNames[] = { "PRINTF", "TEXREPLACE", "DEBUGGER", + "UI", "SCEAUDIO", "SCECTRL", "SCEDISP", diff --git a/Common/UI/Root.cpp b/Common/UI/Root.cpp index b2e2a56967..1054d75cbf 100644 --- a/Common/UI/Root.cpp +++ b/Common/UI/Root.cpp @@ -368,7 +368,7 @@ void UpdateViewHierarchy(ViewGroup *root) { frameCount++; if (!root) { - ERROR_LOG(Log::System, "Tried to update a view hierarchy from a zero pointer root"); + ERROR_LOG(Log::UI, "Tried to update a view hierarchy from a zero pointer root"); return; } diff --git a/Common/UI/Screen.cpp b/Common/UI/Screen.cpp index f8e69e73c4..145ef7c0a1 100644 --- a/Common/UI/Screen.cpp +++ b/Common/UI/Screen.cpp @@ -19,7 +19,7 @@ void Screen::focusChanged(ScreenFocusChange focusChange) { case ScreenFocusChange::FOCUS_LOST_TOP: eventName = "FOCUS_LOST_TOP"; break; case ScreenFocusChange::FOCUS_BECAME_TOP: eventName = "FOCUS_BECAME_TOP"; break; } - DEBUG_LOG(Log::System, "Screen %s got %s", this->tag(), eventName); + DEBUG_LOG(Log::UI, "Screen %s got %s", this->tag(), eventName); } int Screen::GetRequesterToken() { @@ -45,7 +45,7 @@ void ScreenManager::switchScreen(Screen *screen) { // TODO: inputLock_ ? if (!nextStack_.empty() && screen == nextStack_.front().screen) { - ERROR_LOG(Log::System, "Already switching to this screen"); + ERROR_LOG(Log::UI, "Already switching to this screen"); return; } // Note that if a dialog is found, this will be a silent background switch that @@ -53,12 +53,12 @@ void ScreenManager::switchScreen(Screen *screen) { // until that switch. // TODO: is this still true? if (!nextStack_.empty()) { - ERROR_LOG(Log::System, "Already had a nextStack_! Asynchronous open while doing something? Deleting the new screen."); + ERROR_LOG(Log::UI, "Already had a nextStack_! Asynchronous open while doing something? Deleting the new screen."); delete screen; return; } if (screen == nullptr) { - WARN_LOG(Log::System, "Switching to a zero screen, this can't be good"); + WARN_LOG(Log::UI, "Switching to a zero screen, this can't be good"); } if (stack_.empty() || screen != stack_.back().screen) { if (screen) { @@ -162,7 +162,7 @@ void ScreenManager::deviceRestored(Draw::DrawContext *draw) { } void ScreenManager::resized() { - INFO_LOG(Log::System, "ScreenManager::resized(dp: %dx%d)", g_display.dp_xres, g_display.dp_yres); + INFO_LOG(Log::UI, "ScreenManager::resized(dp: %dx%d)", g_display.dp_xres, g_display.dp_yres); std::lock_guard guard(inputLock_); // Have to notify the whole stack, otherwise there will be problems when going back // to non-top screens. @@ -240,7 +240,7 @@ ScreenRenderFlags ScreenManager::render() { postRenderCb_(getUIContext(), postRenderUserdata_); } } else { - ERROR_LOG(Log::System, "No current screen!"); + ERROR_LOG(Log::UI, "No current screen!"); } processFinishDialog(); @@ -337,7 +337,7 @@ void ScreenManager::pop() { stack_.back().screen->focusChanged(ScreenFocusChange::FOCUS_LOST_TOP); } } else { - ERROR_LOG(Log::System, "Can't pop when stack empty"); + ERROR_LOG(Log::UI, "Can't pop when stack empty"); } } @@ -350,11 +350,11 @@ void ScreenManager::RecreateAllViews() { void ScreenManager::finishDialog(Screen *dialog, DialogResult result) { if (stack_.empty()) { - ERROR_LOG(Log::System, "Must be in a dialog to finishDialog"); + ERROR_LOG(Log::UI, "Must be in a dialog to finishDialog"); return; } if (dialog != stack_.back().screen) { - ERROR_LOG(Log::System, "Wrong dialog being finished!"); + ERROR_LOG(Log::UI, "Wrong dialog being finished!"); return; } dialog->onFinish(result); @@ -393,10 +393,10 @@ void ScreenManager::processFinishDialog() { } if (!caller) { - ERROR_LOG(Log::System, "ERROR: no top screen when finishing dialog"); + ERROR_LOG(Log::UI, "ERROR: no top screen when finishing dialog"); } else if (caller != topScreen()) { // The caller may get confused if we call dialogFinished() now. - WARN_LOG(Log::System, "Skipping non-top dialog when finishing dialog."); + WARN_LOG(Log::UI, "Skipping non-top dialog when finishing dialog."); } else { caller->dialogFinished(dialogFinished_, dialogResult_); } diff --git a/Common/UI/ViewGroup.cpp b/Common/UI/ViewGroup.cpp index cb3d1683eb..9eff577298 100644 --- a/Common/UI/ViewGroup.cpp +++ b/Common/UI/ViewGroup.cpp @@ -329,7 +329,7 @@ float GetTargetScore(const Point2D &originPos, int originIndex, const View *orig float vertOverlap = VerticalOverlap(origin->GetBounds(), destination->GetBounds()); if (horizOverlap == 1.0f && vertOverlap == 1.0f) { if (direction != FOCUS_PREV_PAGE && direction != FOCUS_NEXT_PAGE) { - INFO_LOG(Log::System, "Contain overlap"); + INFO_LOG(Log::UI, "Contain overlap"); return 0.0; } } @@ -386,7 +386,7 @@ float GetTargetScore(const Point2D &originPos, int originIndex, const View *orig break; case FOCUS_PREV: case FOCUS_NEXT: - ERROR_LOG(Log::System, "Invalid focus direction"); + ERROR_LOG(Log::UI, "Invalid focus direction"); break; } @@ -408,7 +408,7 @@ static float GetDirectionScore(int originIndex, const View *origin, View *destin NeighborResult ViewGroup::FindNeighbor(View *view, FocusDirection direction, NeighborResult result) { if (!IsEnabled()) { - INFO_LOG(Log::sceCtrl, "Not enabled"); + INFO_LOG(Log::UI, "Not enabled"); return result; } if (GetVisibility() != V_VISIBLE) { @@ -474,7 +474,7 @@ NeighborResult ViewGroup::FindNeighbor(View *view, FocusDirection direction, Nei return NeighborResult(views_[(num + 1) % views_.size()], 0.0f); default: - ERROR_LOG(Log::System, "Bad focus direction %d", (int)direction); + ERROR_LOG(Log::UI, "Bad focus direction %d", (int)direction); return result; } } @@ -889,7 +889,7 @@ void AnchorLayout::Layout() { GridLayout::GridLayout(GridLayoutSettings settings, LayoutParams *layoutParams) : ViewGroup(layoutParams), settings_(settings) { if (settings.orientation != ORIENT_HORIZONTAL) - ERROR_LOG(Log::System, "GridLayout: Vertical layouts not yet supported"); + ERROR_LOG(Log::UI, "GridLayout: Vertical layouts not yet supported"); } void GridLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert) { diff --git a/UI/ImDebugger/ImConsole.cpp b/UI/ImDebugger/ImConsole.cpp index c2f87f7f67..55159d2c91 100644 --- a/UI/ImDebugger/ImConsole.cpp +++ b/UI/ImDebugger/ImConsole.cpp @@ -1,5 +1,3 @@ -#pragma once - #include #include "ext/imgui/imgui.h" diff --git a/UI/TabbedDialogScreen.cpp b/UI/TabbedDialogScreen.cpp index b86be62559..0072899369 100644 --- a/UI/TabbedDialogScreen.cpp +++ b/UI/TabbedDialogScreen.cpp @@ -9,7 +9,7 @@ void TabbedUIDialogScreenWithGameBackground::AddTab(const char *tag, std::string_view title, std::function createCallback, bool isSearch) { using namespace UI; - tabHolder_->AddTabDeferred(title, [this, createCallback = std::move(createCallback), tag, title, isSearch]() -> UI::ViewGroup * { + tabHolder_->AddTabDeferred(title, [createCallback = std::move(createCallback), tag]() -> UI::ViewGroup * { ViewGroup *scroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); scroll->SetTag(tag); LinearLayout *contents = new LinearLayoutList(ORIENT_VERTICAL);