Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #9276 from lioncash/core-log4
Core: Convert logging over to fmt pt.4
  • Loading branch information
leoetlino committed Nov 25, 2020
2 parents 140daf5 + 6cd7181 commit e2a019a
Show file tree
Hide file tree
Showing 29 changed files with 910 additions and 890 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Core/IOS/ES/Identity.cpp
Expand Up @@ -181,7 +181,7 @@ ReturnCode ES::VerifySign(const std::vector<u8>& hash, const std::vector<u8>& ec
return ret;
}

INFO_LOG(IOS_ES, "VerifySign: all checks passed");
INFO_LOG_FMT(IOS_ES, "VerifySign: all checks passed");
return IPC_SUCCESS;
}

Expand Down
12 changes: 7 additions & 5 deletions Source/Core/Core/IOS/FS/FileSystemProxy.cpp
Expand Up @@ -57,9 +57,10 @@ template <typename... Args>
static void LogResult(ResultCode code, std::string_view format, Args&&... args)
{
const std::string command = fmt::format(format, std::forward<Args>(args)...);
GENERIC_LOG(Common::Log::IOS_FS,
(code == ResultCode::Success ? Common::Log::LINFO : Common::Log::LERROR),
"%s: result %d", command.c_str(), ConvertResult(code));
const auto type = code == ResultCode::Success ? Common::Log::LINFO : Common::Log::LERROR;

GENERIC_LOG_FMT(Common::Log::IOS_FS, type, "Command: {}: Result {}", command,
ConvertResult(code));
}

template <typename T, typename... Args>
Expand Down Expand Up @@ -544,7 +545,8 @@ IPCCommandResult FS::SetFileVersionControl(const Handle& handle, const IOCtlRequ
return GetFSReply(ConvertResult(params.Error()));

// FS_SetFileVersionControl(ctx->uid, params->path, params->attribute)
ERROR_LOG(IOS_FS, "SetFileVersionControl(%s, 0x%x): Stubbed", params->path, params->attribute);
ERROR_LOG_FMT(IOS_FS, "SetFileVersionControl({}, {:#x}): Stubbed", params->path,
params->attribute);
return GetFSReply(IPC_SUCCESS);
}

Expand Down Expand Up @@ -586,7 +588,7 @@ IPCCommandResult FS::GetUsage(const Handle& handle, const IOCtlVRequest& request

IPCCommandResult FS::Shutdown(const Handle& handle, const IOCtlRequest& request)
{
INFO_LOG(IOS_FS, "Shutdown");
INFO_LOG_FMT(IOS_FS, "Shutdown");
return GetFSReply(IPC_SUCCESS);
}
} // namespace IOS::HLE::Device
18 changes: 9 additions & 9 deletions Source/Core/Core/IOS/FS/HostBackend/FS.cpp
Expand Up @@ -156,7 +156,7 @@ void HostFileSystem::LoadFst()
const auto root_entry = parse_entry(parse_entry, 0);
if (!root_entry.has_value())
{
ERROR_LOG(IOS_FS, "Failed to parse FST: at least one of the entries was invalid");
ERROR_LOG_FMT(IOS_FS, "Failed to parse FST: at least one of the entries was invalid");
return;
}
m_root_entry = *root_entry;
Expand All @@ -182,12 +182,12 @@ void HostFileSystem::SaveFst()
File::IOFile file{temp_path, "wb"};
if (!file.WriteArray(to_write.data(), to_write.size()))
{
PanicAlert("IOS_FS: Failed to write new FST");
PanicAlertFmt("IOS_FS: Failed to write new FST");
return;
}
}
if (!File::Rename(temp_path, dest_path))
PanicAlert("IOS_FS: Failed to rename temporary FST file");
PanicAlertFmt("IOS_FS: Failed to rename temporary FST file");
}

HostFileSystem::FstEntry* HostFileSystem::GetFstEntryForPath(const std::string& path)
Expand Down Expand Up @@ -218,7 +218,7 @@ HostFileSystem::FstEntry* HostFileSystem::GetFstEntryForPath(const std::string&
// Fall back to dummy data to avoid breaking existing filesystems.
// This code path is also reached when creating a new file or directory;
// proper metadata is filled in later.
INFO_LOG(IOS_FS, "Creating a default entry for %s", complete_path.c_str());
INFO_LOG_FMT(IOS_FS, "Creating a default entry for {}", complete_path);
entry = &entry->children.emplace_back();
entry->name = component;
entry->data.modes = {Mode::ReadWrite, Mode::ReadWrite, Mode::ReadWrite};
Expand All @@ -228,7 +228,7 @@ HostFileSystem::FstEntry* HostFileSystem::GetFstEntryForPath(const std::string&
entry->data.is_file = host_file_info.IsFile();
if (entry->data.is_file && !entry->children.empty())
{
WARN_LOG(IOS_FS, "%s is a file but also has children; clearing children", path.c_str());
WARN_LOG_FMT(IOS_FS, "{} is a file but also has children; clearing children", path);
entry->children.clear();
}

Expand Down Expand Up @@ -382,7 +382,7 @@ ResultCode HostFileSystem::CreateFileOrDirectory(Uid uid, Gid gid, const std::st
const bool ok = is_file ? File::CreateEmptyFile(host_path) : File::CreateDir(host_path);
if (!ok)
{
ERROR_LOG(IOS_FS, "Failed to create file or directory: %s", host_path.c_str());
ERROR_LOG_FMT(IOS_FS, "Failed to create file or directory: {}", host_path);
return ResultCode::UnknownError;
}

Expand Down Expand Up @@ -510,7 +510,7 @@ ResultCode HostFileSystem::Rename(Uid uid, Gid gid, const std::string& old_path,

if (!File::Rename(host_old_path, host_new_path))
{
ERROR_LOG(IOS_FS, "Rename %s to %s - failed", host_old_path.c_str(), host_new_path.c_str());
ERROR_LOG_FMT(IOS_FS, "Rename {} to {} - failed", host_old_path, host_new_path);
return ResultCode::NotFound;
}

Expand Down Expand Up @@ -647,7 +647,7 @@ ResultCode HostFileSystem::SetMetadata(Uid caller_uid, const std::string& path,

Result<NandStats> HostFileSystem::GetNandStats()
{
WARN_LOG(IOS_FS, "GET STATS - returning static values for now");
WARN_LOG_FMT(IOS_FS, "GET STATS - returning static values for now");

// TODO: scrape the real amounts from somewhere...
NandStats stats{};
Expand Down Expand Up @@ -681,7 +681,7 @@ Result<DirectoryStats> HostFileSystem::GetDirectoryStats(const std::string& wii_
}
else
{
WARN_LOG(IOS_FS, "fsBlock failed, cannot find directory: %s", path.c_str());
WARN_LOG_FMT(IOS_FS, "fsBlock failed, cannot find directory: {}", path);
}
return stats;
}
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/Core/IOS/FS/HostBackend/File.cpp
Expand Up @@ -47,15 +47,15 @@ std::shared_ptr<File::IOFile> HostFileSystem::OpenHostFile(const std::string& ho
while (!file.Open(host_path, "r+b"))
{
const bool try_again =
PanicYesNo("File \"%s\" could not be opened!\n"
"This may happen with improper permissions or use by another process.\n"
"Press \"Yes\" to make another attempt.",
host_path.c_str());
PanicYesNoFmt("File \"{}\" could not be opened!\n"
"This may happen with improper permissions or use by another process.\n"
"Press \"Yes\" to make another attempt.",
host_path);

if (!try_again)
{
// We've failed to open the file:
ERROR_LOG(IOS_FS, "OpenHostFile %s", host_path.c_str());
ERROR_LOG_FMT(IOS_FS, "OpenHostFile {}", host_path);
return nullptr;
}
}
Expand Down

0 comments on commit e2a019a

Please sign in to comment.