Remove legacy LOADER log channel

This commit is contained in:
Nekotekina 2020-02-01 07:36:53 +03:00
parent d9a0619ddd
commit 3eca2d5d6c
17 changed files with 377 additions and 361 deletions

View file

@ -8,11 +8,13 @@
#include "Emu/VFS.h"
#include "unpkg.h"
LOG_CHANNEL(pkg_log);
bool pkg_install(const std::string& path, atomic_t<double>& sync)
{
if (!fs::is_file(path))
{
LOG_ERROR(LOADER, "PKG file not found!");
pkg_log.error("PKG file not found!");
return false;
}
@ -76,13 +78,13 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
if (archive_read(&header, sizeof(header)) != sizeof(header))
{
LOG_ERROR(LOADER, "PKG file is too short!");
pkg_log.error("PKG file is too short!");
return false;
}
if (header.pkg_magic != "\x7FPKG"_u32)
{
LOG_ERROR(LOADER, "Not a PKG file!");
pkg_log.error("Not a PKG file!");
return false;
}
@ -92,7 +94,7 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
case PKG_RELEASE_TYPE_RELEASE: break;
default:
{
LOG_ERROR(LOADER, "Unknown PKG type (0x%x)", type);
pkg_log.error("Unknown PKG type (0x%x)", type);
return false;
}
}
@ -103,7 +105,7 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
case PKG_PLATFORM_TYPE_PSP: break;
default:
{
LOG_ERROR(LOADER, "Unknown PKG platform (0x%x)", platform);
pkg_log.error("Unknown PKG platform (0x%x)", platform);
return false;
}
}
@ -113,7 +115,7 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
// Check if multi-files pkg
if (path.size() < 7 || path.compare(path.size() - 7, 7, "_00.pkg", 7) != 0)
{
LOG_ERROR(LOADER, "PKG file size mismatch (pkg_size=0x%llx)", header.pkg_size);
pkg_log.error("PKG file size mismatch (pkg_size=0x%llx)", header.pkg_size);
return false;
}
@ -126,7 +128,7 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
fs::file archive_file(archive_filename);
if (!archive_file)
{
LOG_ERROR(LOADER, "Missing part of the multi-files pkg: %s", archive_filename);
pkg_log.error("Missing part of the multi-files pkg: %s", archive_filename);
return false;
}
@ -137,7 +139,7 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
if (header.data_size + header.data_offset > header.pkg_size)
{
LOG_ERROR(LOADER, "PKG data size mismatch (data_size=0x%llx, data_offset=0x%llx, file_size=0x%llx)", header.data_size, header.data_offset, header.pkg_size);
pkg_log.error("PKG data size mismatch (data_size=0x%llx, data_offset=0x%llx, file_size=0x%llx)", header.data_size, header.data_offset, header.pkg_size);
return false;
}
@ -211,7 +213,7 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
if (!fs::create_path(dir))
{
LOG_ERROR(LOADER, "PKG: Could not create the installation directory %s", dir);
pkg_log.error("PKG: Could not create the installation directory %s", dir);
return false;
}
@ -314,7 +316,7 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
if (entry.name_size > 256)
{
num_failures++;
LOG_ERROR(LOADER, "PKG name size is too big (0x%x)", entry.name_size);
pkg_log.error("PKG name size is too big (0x%x)", entry.name_size);
continue;
}
@ -322,7 +324,7 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
std::string name{reinterpret_cast<char*>(buf.get()), entry.name_size};
LOG_NOTICE(LOADER, "Entry 0x%08x: %s", entry.type, name);
pkg_log.notice("Entry 0x%08x: %s", entry.type, name);
switch (entry.type & 0xff)
{
@ -344,7 +346,7 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
if (did_overwrite && (entry.type & PKG_FILE_ENTRY_OVERWRITE) == 0)
{
LOG_NOTICE(LOADER, "Didn't overwrite %s", name);
pkg_log.notice("Didn't overwrite %s", name);
break;
}
@ -358,14 +360,14 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
if (decrypt(entry.file_offset + pos, block_size, is_psp ? PKG_AES_KEY2 : dec_key.data()) != block_size)
{
extract_success = false;
LOG_ERROR(LOADER, "Failed to extract file %s", path);
pkg_log.error("Failed to extract file %s", path);
break;
}
if (out.write(buf.get(), block_size) != block_size)
{
extract_success = false;
LOG_ERROR(LOADER, "Failed to write file %s", path);
pkg_log.error("Failed to write file %s", path);
break;
}
@ -373,7 +375,7 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
{
if (was_null)
{
LOG_ERROR(LOADER, "Package installation cancelled: %s", dir);
pkg_log.error("Package installation cancelled: %s", dir);
out.close();
fs::remove_all(dir, true);
return false;
@ -385,14 +387,14 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
}
if (extract_success)
{
{
if (did_overwrite)
{
LOG_WARNING(LOADER, "Overwritten file %s", name);
pkg_log.warning("Overwritten file %s", name);
}
else
{
LOG_NOTICE(LOADER, "Created file %s", name);
pkg_log.notice("Created file %s", name);
}
}
else
@ -403,7 +405,7 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
else
{
num_failures++;
LOG_ERROR(LOADER, "Failed to create file %s", path);
pkg_log.error("Failed to create file %s", path);
}
break;
@ -416,16 +418,16 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
if (fs::create_dir(path))
{
LOG_NOTICE(LOADER, "Created directory %s", name);
pkg_log.notice("Created directory %s", name);
}
else if (fs::is_dir(path))
{
LOG_WARNING(LOADER, "Reused existing directory %s", name);
pkg_log.warning("Reused existing directory %s", name);
}
else
{
num_failures++;
LOG_ERROR(LOADER, "Failed to create directory %s", path);
pkg_log.error("Failed to create directory %s", path);
}
break;
@ -434,19 +436,19 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
default:
{
num_failures++;
LOG_ERROR(LOADER, "Unknown PKG entry type (0x%x) %s", entry.type, name);
pkg_log.error("Unknown PKG entry type (0x%x) %s", entry.type, name);
}
}
}
if (num_failures == 0)
{
LOG_SUCCESS(LOADER, "Package successfully installed to %s", dir);
pkg_log.success("Package successfully installed to %s", dir);
}
else
{
fs::remove_all(dir, true);
LOG_ERROR(LOADER, "Package installation failed: %s", dir);
pkg_log.error("Package installation failed: %s", dir);
}
return num_failures == 0;
}