Log: Simplify macros

This commit is contained in:
Stenzek
2024-05-23 20:55:28 +10:00
parent 792717e03e
commit 4e922a34a7
144 changed files with 2273 additions and 2363 deletions

View File

@ -151,7 +151,7 @@ bool GameList::GetExeListEntry(const std::string& path, GameList::Entry* entry)
if (!BIOS::IsValidPSExeHeader(header, file_size))
{
Log_WarningFmt("{} is not a valid PS-EXE", path);
WARNING_LOG("{} is not a valid PS-EXE", path);
return false;
}
@ -286,7 +286,7 @@ bool GameList::GetDiscListEntry(const std::string& path, Entry* entry)
{
if (!cdi->SwitchSubImage(i, nullptr))
{
Log_ErrorFmt("Failed to switch to subimage {} in '{}'", i, entry->path);
ERROR_LOG("Failed to switch to subimage {} in '{}'", i, entry->path);
continue;
}
@ -323,7 +323,7 @@ bool GameList::LoadEntriesFromCache(ByteStream* stream)
if (!stream->ReadU32(&file_signature) || !stream->ReadU32(&file_version) ||
file_signature != GAME_LIST_CACHE_SIGNATURE || file_version != GAME_LIST_CACHE_VERSION)
{
Log_WarningPrint("Game list cache is corrupted");
WARNING_LOG("Game list cache is corrupted");
return false;
}
@ -348,7 +348,7 @@ bool GameList::LoadEntriesFromCache(ByteStream* stream)
region >= static_cast<u8>(DiscRegion::Count) || type >= static_cast<u8>(EntryType::Count) ||
compatibility_rating >= static_cast<u8>(GameDatabase::CompatibilityRating::Count))
{
Log_WarningPrint("Game list cache entry is corrupted");
WARNING_LOG("Game list cache entry is corrupted");
return false;
}
@ -409,7 +409,7 @@ void GameList::LoadCache()
if (!LoadEntriesFromCache(stream.get()))
{
Log_WarningFmt("Deleting corrupted cache file '{}'", Path::GetFileName(filename));
WARNING_LOG("Deleting corrupted cache file '{}'", Path::GetFileName(filename));
stream.reset();
s_cache_map.clear();
DeleteCacheFile();
@ -438,7 +438,7 @@ bool GameList::OpenCacheForWriting()
s_cache_write_stream.reset();
}
Log_InfoFmt("Creating new game list cache file: '{}'", Path::GetFileName(cache_filename));
INFO_LOG("Creating new game list cache file: '{}'", Path::GetFileName(cache_filename));
s_cache_write_stream = ByteStream::OpenFile(
cache_filename.c_str(), BYTESTREAM_OPEN_CREATE | BYTESTREAM_OPEN_TRUNCATE | BYTESTREAM_OPEN_WRITE);
@ -449,7 +449,7 @@ bool GameList::OpenCacheForWriting()
if (!s_cache_write_stream->WriteU32(GAME_LIST_CACHE_SIGNATURE) ||
!s_cache_write_stream->WriteU32(GAME_LIST_CACHE_VERSION))
{
Log_ErrorPrint("Failed to write game list cache header");
ERROR_LOG("Failed to write game list cache header");
s_cache_write_stream.reset();
FileSystem::DeleteFile(cache_filename.c_str());
return false;
@ -477,9 +477,9 @@ void GameList::DeleteCacheFile()
Error error;
if (FileSystem::DeleteFile(filename.c_str(), &error))
Log_InfoFmt("Deleted game list cache '{}'", Path::GetFileName(filename));
INFO_LOG("Deleted game list cache '{}'", Path::GetFileName(filename));
else
Log_WarningFmt("Failed to delete game list cache '{}': {}", Path::GetFileName(filename), error.GetDescription());
WARNING_LOG("Failed to delete game list cache '{}': {}", Path::GetFileName(filename), error.GetDescription());
}
static bool IsPathExcluded(const std::vector<std::string>& excluded_paths, const std::string& path)
@ -492,7 +492,7 @@ void GameList::ScanDirectory(const char* path, bool recursive, bool only_cache,
const std::vector<std::string>& excluded_paths, const PlayedTimeMap& played_time_map,
ProgressCallback* progress)
{
Log_InfoFmt("Scanning {}{}", path, recursive ? " (recursively)" : "");
INFO_LOG("Scanning {}{}", path, recursive ? " (recursively)" : "");
progress->SetStatusText(SmallString::from_format(TRANSLATE_FS("GameList", "Scanning directory '{}'..."), path));
@ -559,7 +559,7 @@ bool GameList::ScanFile(std::string path, std::time_t timestamp, std::unique_loc
// don't block UI while scanning
lock.unlock();
Log_DevFmt("Scanning '{}'...", path);
DEV_LOG("Scanning '{}'...", path);
Entry entry;
if (!PopulateEntryFromPath(path, &entry))
@ -571,7 +571,7 @@ bool GameList::ScanFile(std::string path, std::time_t timestamp, std::unique_loc
if (s_cache_write_stream || OpenCacheForWriting())
{
if (!WriteEntryToCache(&entry)) [[unlikely]]
Log_WarningFmt("Failed to write entry '{}' to cache", entry.path);
WARNING_LOG("Failed to write entry '{}' to cache", entry.path);
}
auto iter = played_time_map.find(entry.serial);
@ -781,7 +781,7 @@ void GameList::CreateDiscSetEntries(const PlayedTimeMap& played_time_map)
}
if (!found_another_disc)
{
Log_DevFmt("Not creating disc set {}, only one disc found", disc_set_name);
DEV_LOG("Not creating disc set {}, only one disc found", disc_set_name);
continue;
}
@ -834,7 +834,7 @@ void GameList::CreateDiscSetEntries(const PlayedTimeMap& played_time_map)
continue;
}
Log_DevFmt("Adding {} to disc set {}", Path::GetFileName(other_entry.path), disc_set_name);
DEV_LOG("Adding {} to disc set {}", Path::GetFileName(other_entry.path), disc_set_name);
other_entry.disc_set_member = true;
set_entry.last_modified_time = std::min(set_entry.last_modified_time, other_entry.last_modified_time);
set_entry.file_size += other_entry.file_size;
@ -842,7 +842,7 @@ void GameList::CreateDiscSetEntries(const PlayedTimeMap& played_time_map)
num_parts++;
}
Log_DevFmt("Created disc set {} from {} entries", disc_set_name, num_parts);
DEV_LOG("Created disc set {} from {} entries", disc_set_name, num_parts);
// entry is done :)
s_entries.push_back(std::move(set_entry));
@ -947,7 +947,7 @@ bool GameList::ParsePlayedTimeLine(char* line, std::string& serial, PlayedTimeEn
size_t len = std::strlen(line);
if (len != (PLAYED_TIME_LINE_LENGTH + 1)) // \n
{
Log_WarningFmt("Malformed line: '{}'", line);
WARNING_LOG("Malformed line: '{}'", line);
return false;
}
@ -961,7 +961,7 @@ bool GameList::ParsePlayedTimeLine(char* line, std::string& serial, PlayedTimeEn
const std::optional<u64> last_played_time(StringUtil::FromChars<u64>(last_played_time_tok));
if (serial_tok.empty() || !last_played_time.has_value() || !total_played_time.has_value())
{
Log_WarningFmt("Malformed line: '{}'", line);
WARNING_LOG("Malformed line: '{}'", line);
return false;
}
@ -1010,7 +1010,7 @@ GameList::PlayedTimeMap GameList::LoadPlayedTimeMap(const std::string& path)
if (ret.find(serial) != ret.end())
{
Log_WarningFmt("Duplicate entry: '%s'", serial);
WARNING_LOG("Duplicate entry: '%s'", serial);
continue;
}
@ -1043,7 +1043,7 @@ GameList::PlayedTimeEntry GameList::UpdatePlayedTimeFile(const std::string& path
if (!fp)
{
Log_ErrorFmt("Failed to open '{}' for update.", path);
ERROR_LOG("Failed to open '{}' for update.", path);
return new_entry;
}
@ -1074,7 +1074,7 @@ GameList::PlayedTimeEntry GameList::UpdatePlayedTimeFile(const std::string& path
if (FileSystem::FSeek64(fp.get(), line_pos, SEEK_SET) != 0 ||
std::fwrite(new_line.data(), new_line.length(), 1, fp.get()) != 1)
{
Log_ErrorFmt("Failed to update '%s'.", path);
ERROR_LOG("Failed to update '%s'.", path);
}
return line_entry;
@ -1087,7 +1087,7 @@ GameList::PlayedTimeEntry GameList::UpdatePlayedTimeFile(const std::string& path
if (FileSystem::FSeek64(fp.get(), 0, SEEK_END) != 0 ||
std::fwrite(new_line.data(), new_line.length(), 1, fp.get()) != 1)
{
Log_ErrorFmt("Failed to write '%s'.", path);
ERROR_LOG("Failed to write '%s'.", path);
}
}
@ -1100,8 +1100,8 @@ void GameList::AddPlayedTimeForSerial(const std::string& serial, std::time_t las
return;
const PlayedTimeEntry pt(UpdatePlayedTimeFile(GetPlayedTimeFile(), serial, last_time, add_time));
Log_VerboseFmt("Add {} seconds play time to {} -> now {}", static_cast<unsigned>(add_time), serial.c_str(),
static_cast<unsigned>(pt.total_played_time));
VERBOSE_LOG("Add {} seconds play time to {} -> now {}", static_cast<unsigned>(add_time), serial.c_str(),
static_cast<unsigned>(pt.total_played_time));
std::unique_lock<std::recursive_mutex> lock(s_mutex);
for (GameList::Entry& entry : s_entries)