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

@ -74,7 +74,7 @@ AutoUpdaterDialog::AutoUpdaterDialog(QWidget* parent /* = nullptr */) : QDialog(
m_http = HTTPDownloader::Create(Host::GetHTTPUserAgent());
if (!m_http)
Log_ErrorPrint("Failed to create HTTP downloader, auto updater will not be available.");
ERROR_LOG("Failed to create HTTP downloader, auto updater will not be available.");
}
AutoUpdaterDialog::~AutoUpdaterDialog() = default;
@ -86,7 +86,7 @@ bool AutoUpdaterDialog::isSupported()
// For Linux, we need to check whether we're running from the appimage.
if (!std::getenv("APPIMAGE"))
{
Log_InfoPrint("We're a CI release, but not running from an AppImage. Disabling automatic updater.");
INFO_LOG("We're a CI release, but not running from an AppImage. Disabling automatic updater.");
return false;
}
@ -165,7 +165,7 @@ void AutoUpdaterDialog::httpPollTimerPoll()
if (!m_http->HasAnyRequests())
{
Log_VerbosePrint("All HTTP requests done.");
VERBOSE_LOG("All HTTP requests done.");
m_http_poll_timer->stop();
}
}
@ -465,16 +465,16 @@ bool AutoUpdaterDialog::updateNeeded() const
{
QString last_checked_sha = QString::fromStdString(Host::GetBaseStringSettingValue("AutoUpdater", "LastVersion"));
Log_InfoFmt("Current SHA: {}", g_scm_hash_str);
Log_InfoFmt("Latest SHA: {}", m_latest_sha.toUtf8().constData());
Log_InfoFmt("Last Checked SHA: {}", last_checked_sha.toUtf8().constData());
INFO_LOG("Current SHA: {}", g_scm_hash_str);
INFO_LOG("Latest SHA: {}", m_latest_sha.toUtf8().constData());
INFO_LOG("Last Checked SHA: {}", last_checked_sha.toUtf8().constData());
if (m_latest_sha == g_scm_hash_str || m_latest_sha == last_checked_sha)
{
Log_InfoPrint("No update needed.");
INFO_LOG("No update needed.");
return false;
}
Log_InfoPrint("Update needed.");
INFO_LOG("Update needed.");
return true;
}
@ -697,8 +697,8 @@ bool AutoUpdaterDialog::processUpdate(const std::vector<u8>& update_data)
zip_file.close();
}
Log_InfoFmt("Beginning update:\nUpdater path: {}\nZip path: {}\nStaging directory: {}\nOutput directory: {}",
updater_app, zip_path, staging_directory, bundle_path.value());
INFO_LOG("Beginning update:\nUpdater path: {}\nZip path: {}\nStaging directory: {}\nOutput directory: {}",
updater_app, zip_path, staging_directory, bundle_path.value());
const std::string_view args[] = {
zip_path,
@ -735,9 +735,9 @@ bool AutoUpdaterDialog::processUpdate(const std::vector<u8>& update_data)
const QString new_appimage_path(qappimage_path + QStringLiteral(".new"));
const QString backup_appimage_path(qappimage_path + QStringLiteral(".backup"));
Log_InfoFmt("APPIMAGE = {}", appimage_path);
Log_InfoFmt("Backup AppImage path = {}", backup_appimage_path.toUtf8().constData());
Log_InfoFmt("New AppImage path = {}", new_appimage_path.toUtf8().constData());
INFO_LOG("APPIMAGE = {}", appimage_path);
INFO_LOG("Backup AppImage path = {}", backup_appimage_path.toUtf8().constData());
INFO_LOG("New AppImage path = {}", new_appimage_path.toUtf8().constData());
// Remove old "new" appimage and existing backup appimage.
if (QFile::exists(new_appimage_path) && !QFile::remove(new_appimage_path))
@ -809,11 +809,10 @@ void AutoUpdaterDialog::cleanupAfterUpdate()
if (!QFile::exists(backup_appimage_path))
return;
Log_InfoPrint(QStringLiteral("Removing backup AppImage %1").arg(backup_appimage_path).toStdString().c_str());
INFO_LOG(QStringLiteral("Removing backup AppImage %1").arg(backup_appimage_path).toStdString().c_str());
if (!QFile::remove(backup_appimage_path))
{
Log_ErrorPrint(
QStringLiteral("Failed to remove backup AppImage %1").arg(backup_appimage_path).toStdString().c_str());
ERROR_LOG(QStringLiteral("Failed to remove backup AppImage %1").arg(backup_appimage_path).toStdString().c_str());
}
}

View File

@ -481,7 +481,7 @@ void ControllerBindingWidget::bindBindingWidgets(QWidget* parent)
InputBindingWidget* widget = parent->findChild<InputBindingWidget*>(QString::fromUtf8(bi.name));
if (!widget)
{
Log_ErrorFmt("No widget found for '{}' ({})", bi.name, m_controller_info->name);
ERROR_LOG("No widget found for '{}' ({})", bi.name, m_controller_info->name);
continue;
}

View File

@ -84,7 +84,7 @@ void DisplayWidget::updateRelativeMode(bool enabled)
if (m_relative_mouse_enabled == enabled && m_clip_mouse_enabled == clip_cursor)
return;
Log_InfoFmt("updateRelativeMode(): relative={}, clip={}", enabled ? "yes" : "no", clip_cursor ? "yes" : "no");
INFO_LOG("updateRelativeMode(): relative={}, clip={}", enabled ? "yes" : "no", clip_cursor ? "yes" : "no");
if (!clip_cursor && m_clip_mouse_enabled)
{
@ -95,7 +95,7 @@ void DisplayWidget::updateRelativeMode(bool enabled)
if (m_relative_mouse_enabled == enabled)
return;
Log_InfoFmt("updateRelativeMode(): relative={}", enabled ? "yes" : "no");
INFO_LOG("updateRelativeMode(): relative={}", enabled ? "yes" : "no");
#endif
if (enabled)
@ -126,12 +126,12 @@ void DisplayWidget::updateCursor(bool hidden)
m_cursor_hidden = hidden;
if (hidden)
{
Log_DevPrint("updateCursor(): Cursor is now hidden");
DEV_LOG("updateCursor(): Cursor is now hidden");
setCursor(Qt::BlankCursor);
}
else
{
Log_DevPrint("updateCursor(): Cursor is now shown");
DEV_LOG("updateCursor(): Cursor is now shown");
unsetCursor();
}
}

View File

@ -11,7 +11,7 @@ GDBConnection::GDBConnection(GDBServer* parent, intptr_t descriptor) : QTcpSocke
{
if (!setSocketDescriptor(descriptor))
{
Log_ErrorFmt("{} failed to set socket descriptor: {}", descriptor, errorString().toStdString());
ERROR_LOG("{} failed to set socket descriptor: {}", descriptor, errorString().toStdString());
deleteLater();
return;
}
@ -21,7 +21,7 @@ GDBConnection::GDBConnection(GDBServer* parent, intptr_t descriptor) : QTcpSocke
connect(this, &QTcpSocket::readyRead, this, &GDBConnection::receivedData);
connect(this, &QTcpSocket::disconnected, this, &GDBConnection::gotDisconnected);
Log_InfoFmt("{} client connected", m_descriptor);
INFO_LOG("{} client connected", m_descriptor);
m_seen_resume = System::IsPaused();
g_emu_thread->setSystemPaused(true);
@ -29,7 +29,7 @@ GDBConnection::GDBConnection(GDBServer* parent, intptr_t descriptor) : QTcpSocke
void GDBConnection::gotDisconnected()
{
Log_InfoFmt("{} client disconnected", m_descriptor);
INFO_LOG("{} client disconnected", m_descriptor);
deleteLater();
}
@ -46,19 +46,19 @@ void GDBConnection::receivedData()
if (GDBProtocol::IsPacketInterrupt(m_readBuffer))
{
Log_DebugFmt("{} > Interrupt request", m_descriptor);
DEBUG_LOG("{} > Interrupt request", m_descriptor);
g_emu_thread->setSystemPaused(true);
m_readBuffer.erase();
}
else if (GDBProtocol::IsPacketContinue(m_readBuffer))
{
Log_DebugFmt("{} > Continue request", m_descriptor);
DEBUG_LOG("{} > Continue request", m_descriptor);
g_emu_thread->setSystemPaused(false);
m_readBuffer.erase();
}
else if (GDBProtocol::IsPacketComplete(m_readBuffer))
{
Log_DebugFmt("{} > %s", m_descriptor, m_readBuffer.c_str());
DEBUG_LOG("{} > %s", m_descriptor, m_readBuffer.c_str());
writePacket(GDBProtocol::ProcessPacket(m_readBuffer));
m_readBuffer.erase();
}
@ -66,7 +66,7 @@ void GDBConnection::receivedData()
}
if (bytesRead == -1)
{
Log_ErrorFmt("{} failed to read from socket: %s", m_descriptor, errorString().toStdString());
ERROR_LOG("{} failed to read from socket: %s", m_descriptor, errorString().toStdString());
}
}
@ -89,7 +89,7 @@ void GDBConnection::onEmulationResumed()
void GDBConnection::writePacket(std::string_view packet)
{
Log_DebugFmt("{} < {}", m_descriptor, packet);
DEBUG_LOG("{} < {}", m_descriptor, packet);
if (write(packet.data(), packet.length()) == -1)
Log_ErrorFmt("{} failed to write to socket: {}", m_descriptor, errorString().toStdString());
ERROR_LOG("{} failed to write to socket: {}", m_descriptor, errorString().toStdString());
}

View File

@ -25,11 +25,11 @@ void GDBServer::start(quint16 port)
if (!listen(QHostAddress::LocalHost, port))
{
Log_ErrorFmt("Failed to listen on TCP port {} for GDB server: {}", port, errorString().toUtf8().constData());
ERROR_LOG("Failed to listen on TCP port {} for GDB server: {}", port, errorString().toUtf8().constData());
return;
}
Log_InfoFmt("GDB server listening on TCP port {}", port);
INFO_LOG("GDB server listening on TCP port {}", port);
}
void GDBServer::stop()
@ -37,7 +37,7 @@ void GDBServer::stop()
if (isListening())
{
close();
Log_InfoPrint("GDB server stopped");
INFO_LOG("GDB server stopped");
}
for (QObject* connection : children())

View File

@ -292,7 +292,7 @@ void LogWindow::logCallback(void* pUserParam, const char* channelName, const cha
qmessage.append(QUtf8StringView(message.data(), message.length()));
qmessage.append(QChar('\n'));
const QLatin1StringView qchannel((level <= LOGLEVEL_PERF) ? functionName : channelName);
const QLatin1StringView qchannel((level <= LOGLEVEL_WARNING) ? functionName : channelName);
if (g_emu_thread->isOnUIThread())
{
@ -331,16 +331,14 @@ void LogWindow::appendMessage(const QLatin1StringView& channel, quint32 level, c
temp_cursor.movePosition(QTextCursor::End);
{
static constexpr const QChar level_characters[LOGLEVEL_COUNT] = {'X', 'E', 'W', 'P', 'I', 'V', 'D', 'R', 'B', 'T'};
static constexpr const QChar level_characters[LOGLEVEL_COUNT] = {'X', 'E', 'W', 'I', 'V', 'D', 'B', 'T'};
static constexpr const QColor level_colors[LOGLEVEL_COUNT] = {
QColor(255, 255, 255), // NONE
QColor(0xE7, 0x48, 0x56), // ERROR, Red Intensity
QColor(0xF9, 0xF1, 0xA5), // WARNING, Yellow Intensity
QColor(0xB4, 0x00, 0x9E), // PERF, Purple Intensity
QColor(0xF2, 0xF2, 0xF2), // INFO, White Intensity
QColor(0x16, 0xC6, 0x0C), // VERBOSE, Green Intensity
QColor(0xCC, 0xCC, 0xCC), // DEV, White
QColor(0x61, 0xD6, 0xD6), // PROFILE, Cyan Intensity
QColor(0x13, 0xA1, 0x0E), // DEBUG, Green
QColor(0x00, 0x37, 0xDA), // TRACE, Blue
};
@ -358,7 +356,7 @@ void LogWindow::appendMessage(const QLatin1StringView& channel, quint32 level, c
temp_cursor.insertText(qtimestamp);
}
const QString qchannel = (level <= LOGLEVEL_PERF) ?
const QString qchannel = (level <= LOGLEVEL_WARNING) ?
QStringLiteral("%1(%2): ").arg(level_characters[level]).arg(channel) :
QStringLiteral("%1/%2: ").arg(level_characters[level]).arg(channel);
format.setForeground(QBrush(channel_color));

View File

@ -246,10 +246,9 @@ bool MainWindow::nativeEvent(const QByteArray& eventType, void* message, qintptr
std::optional<WindowInfo> MainWindow::acquireRenderWindow(bool recreate_window, bool fullscreen, bool render_to_main,
bool surfaceless, bool use_main_window_pos)
{
Log_DevFmt(
"acquireRenderWindow() recreate={} fullscreen={} render_to_main={} surfaceless={} use_main_window_pos={}",
recreate_window ? "true" : "false", fullscreen ? "true" : "false", render_to_main ? "true" : "false",
surfaceless ? "true" : "false", use_main_window_pos ? "true" : "false");
DEV_LOG("acquireRenderWindow() recreate={} fullscreen={} render_to_main={} surfaceless={} use_main_window_pos={}",
recreate_window ? "true" : "false", fullscreen ? "true" : "false", render_to_main ? "true" : "false",
surfaceless ? "true" : "false", use_main_window_pos ? "true" : "false");
QWidget* container =
m_display_container ? static_cast<QWidget*>(m_display_container) : static_cast<QWidget*>(m_display_widget);
@ -269,7 +268,7 @@ std::optional<WindowInfo> MainWindow::acquireRenderWindow(bool recreate_window,
if (m_display_created && !recreate_window && !is_rendering_to_main && !render_to_main &&
has_container == needs_container && !needs_container && !changing_surfaceless)
{
Log_DevFmt("Toggling to {} without recreating surface", (fullscreen ? "fullscreen" : "windowed"));
DEV_LOG("Toggling to {} without recreating surface", (fullscreen ? "fullscreen" : "windowed"));
// since we don't destroy the display widget, we need to save it here
if (!is_fullscreen && !is_rendering_to_main)

View File

@ -202,7 +202,7 @@ bool QtHost::SaveGameSettings(SettingsInterface* sif, bool delete_if_empty)
// if there's no keys, just toss the whole thing out
if (delete_if_empty && ini->IsEmpty())
{
Log_InfoFmt("Removing empty gamesettings ini {}", Path::GetFileName(ini->GetFileName()));
INFO_LOG("Removing empty gamesettings ini {}", Path::GetFileName(ini->GetFileName()));
if (FileSystem::FileExists(ini->GetFileName().c_str()) &&
!FileSystem::DeleteFile(ini->GetFileName().c_str(), &error))
{
@ -297,7 +297,7 @@ std::optional<bool> QtHost::DownloadFile(QWidget* parent, const QString& title,
bool QtHost::DownloadFile(QWidget* parent, const QString& title, std::string url, const char* path)
{
Log_InfoFmt("Download from {}, saving to {}.", url, path);
INFO_LOG("Download from {}, saving to {}.", url, path);
std::vector<u8> data;
if (!DownloadFile(parent, title, std::move(url), &data).value_or(false) || data.empty())
@ -320,7 +320,7 @@ bool QtHost::DownloadFile(QWidget* parent, const QString& title, std::string url
bool QtHost::DownloadFileFromZip(QWidget* parent, const QString& title, std::string url, const char* zip_filename,
const char* output_path)
{
Log_InfoFmt("Download {} from {}, saving to {}.", zip_filename, url, output_path);
INFO_LOG("Download {} from {}, saving to {}.", zip_filename, url, output_path);
std::vector<u8> data;
if (!DownloadFile(parent, title, std::move(url), &data).value_or(false) || data.empty())
@ -401,7 +401,7 @@ bool QtHost::InitializeConfig(std::string settings_filename)
settings_filename = Path::Combine(EmuFolders::DataRoot, "settings.ini");
const bool settings_exists = FileSystem::FileExists(settings_filename.c_str());
Log_InfoFmt("Loading config from {}.", settings_filename);
INFO_LOG("Loading config from {}.", settings_filename);
s_base_settings_interface = std::make_unique<INISettingsInterface>(std::move(settings_filename));
Host::Internal::SetBaseSettingsLayer(s_base_settings_interface.get());
@ -465,9 +465,9 @@ bool QtHost::SetCriticalFolders()
return false;
// logging of directories in case something goes wrong super early
Log_DevFmt("AppRoot Directory: {}", EmuFolders::AppRoot);
Log_DevFmt("DataRoot Directory: {}", EmuFolders::DataRoot);
Log_DevFmt("Resources Directory: {}", EmuFolders::Resources);
DEV_LOG("AppRoot Directory: {}", EmuFolders::AppRoot);
DEV_LOG("DataRoot Directory: {}", EmuFolders::DataRoot);
DEV_LOG("Resources Directory: {}", EmuFolders::Resources);
// Write crash dumps to the data directory, since that'll be accessible for certain.
CrashHandler::SetWriteDirectory(EmuFolders::DataRoot);
@ -493,7 +493,7 @@ bool QtHost::ShouldUsePortableMode()
void QtHost::SetAppRoot()
{
const std::string program_path = FileSystem::GetProgramPath();
Log_InfoFmt("Program Path: {}", program_path.c_str());
INFO_LOG("Program Path: {}", program_path.c_str());
EmuFolders::AppRoot = Path::Canonicalize(Path::GetDirectory(program_path));
}
@ -1813,9 +1813,9 @@ void Host::ReportFatalError(std::string_view title, std::string_view message)
void Host::ReportErrorAsync(std::string_view title, std::string_view message)
{
if (!title.empty() && !message.empty())
Log_ErrorFmt("ReportErrorAsync: {}: {}", title, message);
ERROR_LOG("ReportErrorAsync: {}: {}", title, message);
else if (!message.empty())
Log_ErrorFmt("ReportErrorAsync: {}", message);
ERROR_LOG("ReportErrorAsync: {}", message);
QMetaObject::invokeMethod(
g_main_window, "reportError", Qt::QueuedConnection,
@ -1913,7 +1913,7 @@ std::optional<std::vector<u8>> Host::ReadResourceFile(std::string_view filename,
const std::string path = QtHost::GetResourcePath(filename, allow_override);
std::optional<std::vector<u8>> ret(FileSystem::ReadBinaryFile(path.c_str()));
if (!ret.has_value())
Log_ErrorFmt("Failed to read resource file '{}'", filename);
ERROR_LOG("Failed to read resource file '{}'", filename);
return ret;
}
@ -1922,7 +1922,7 @@ std::optional<std::string> Host::ReadResourceFileToString(std::string_view filen
const std::string path = QtHost::GetResourcePath(filename, allow_override);
std::optional<std::string> ret(FileSystem::ReadFileToString(path.c_str()));
if (!ret.has_value())
Log_ErrorFmt("Failed to read resource file to string '{}'", filename);
ERROR_LOG("Failed to read resource file to string '{}'", filename);
return ret;
}
@ -1933,7 +1933,7 @@ std::optional<std::time_t> Host::GetResourceFileTimestamp(std::string_view filen
FILESYSTEM_STAT_DATA sd;
if (!FileSystem::StatFile(path.c_str(), &sd))
{
Log_ErrorFmt("Failed to stat resource file '{}'", filename);
ERROR_LOG("Failed to stat resource file '{}'", filename);
return std::nullopt;
}
@ -2055,7 +2055,7 @@ void QtHost::SaveSettings()
Error error;
auto lock = Host::GetSettingsLock();
if (!s_base_settings_interface->Save(&error))
Log_ErrorFmt("Failed to save settings: {}", error.GetDescription());
ERROR_LOG("Failed to save settings: {}", error.GetDescription());
}
if (s_settings_save_timer)
@ -2287,88 +2287,88 @@ bool QtHost::ParseCommandLineParametersAndInitializeConfig(QApplication& app,
}
else if (CHECK_ARG("-batch"))
{
Log_InfoPrint("Command Line: Using batch mode.");
INFO_LOG("Command Line: Using batch mode.");
s_batch_mode = true;
continue;
}
else if (CHECK_ARG("-nogui"))
{
Log_InfoPrint("Command Line: Using NoGUI mode.");
INFO_LOG("Command Line: Using NoGUI mode.");
s_nogui_mode = true;
s_batch_mode = true;
continue;
}
else if (CHECK_ARG("-bios"))
{
Log_InfoPrint("Command Line: Starting BIOS.");
INFO_LOG("Command Line: Starting BIOS.");
AutoBoot(autoboot);
starting_bios = true;
continue;
}
else if (CHECK_ARG("-fastboot"))
{
Log_InfoPrint("Command Line: Forcing fast boot.");
INFO_LOG("Command Line: Forcing fast boot.");
AutoBoot(autoboot)->override_fast_boot = true;
continue;
}
else if (CHECK_ARG("-slowboot"))
{
Log_InfoPrint("Command Line: Forcing slow boot.");
INFO_LOG("Command Line: Forcing slow boot.");
AutoBoot(autoboot)->override_fast_boot = false;
continue;
}
else if (CHECK_ARG("-resume"))
{
state_index = -1;
Log_InfoPrint("Command Line: Loading resume state.");
INFO_LOG("Command Line: Loading resume state.");
continue;
}
else if (CHECK_ARG_PARAM("-state"))
{
state_index = args[++i].toInt();
Log_InfoFmt("Command Line: Loading state index: {}", state_index.value());
INFO_LOG("Command Line: Loading state index: {}", state_index.value());
continue;
}
else if (CHECK_ARG_PARAM("-statefile"))
{
AutoBoot(autoboot)->save_state = args[++i].toStdString();
Log_InfoFmt("Command Line: Loading state file: '{}'", autoboot->save_state);
INFO_LOG("Command Line: Loading state file: '{}'", autoboot->save_state);
continue;
}
else if (CHECK_ARG_PARAM("-exe"))
{
AutoBoot(autoboot)->override_exe = args[++i].toStdString();
Log_InfoFmt("Command Line: Overriding EXE file: '{}'", autoboot->override_exe);
INFO_LOG("Command Line: Overriding EXE file: '{}'", autoboot->override_exe);
continue;
}
else if (CHECK_ARG("-fullscreen"))
{
Log_InfoPrint("Command Line: Using fullscreen.");
INFO_LOG("Command Line: Using fullscreen.");
AutoBoot(autoboot)->override_fullscreen = true;
s_start_fullscreen_ui_fullscreen = true;
continue;
}
else if (CHECK_ARG("-nofullscreen"))
{
Log_InfoPrint("Command Line: Not using fullscreen.");
INFO_LOG("Command Line: Not using fullscreen.");
AutoBoot(autoboot)->override_fullscreen = false;
continue;
}
else if (CHECK_ARG("-portable"))
{
Log_InfoPrint("Command Line: Using portable mode.");
INFO_LOG("Command Line: Using portable mode.");
EmuFolders::DataRoot = EmuFolders::AppRoot;
continue;
}
else if (CHECK_ARG_PARAM("-settings"))
{
settings_filename = args[++i].toStdString();
Log_InfoFmt("Command Line: Overriding settings filename: {}", settings_filename);
INFO_LOG("Command Line: Overriding settings filename: {}", settings_filename);
continue;
}
else if (CHECK_ARG("-bigpicture"))
{
Log_InfoPrint("Command Line: Starting big picture mode.");
INFO_LOG("Command Line: Starting big picture mode.");
s_start_fullscreen_ui = true;
continue;
}

View File

@ -136,7 +136,7 @@ void QtHost::InstallTranslator(QWidget* dialog_parent)
return;
}
Log_InfoFmt("Loaded translation file for language {}", language.toUtf8().constData());
INFO_LOG("Loaded translation file for language {}", language.toUtf8().constData());
qApp->installTranslator(translator);
s_translators.push_back(translator);

View File

@ -622,7 +622,7 @@ void SettingsWindow::openGamePropertiesDialog(const std::string& path, const std
if (image)
dentry = GameDatabase::GetEntryForDisc(image.get());
else
Log_ErrorFmt("Failed to open '{}' for game properties: {}", path, error.GetDescription());
ERROR_LOG("Failed to open '{}' for game properties: {}", path, error.GetDescription());
if (!dentry)
{