Remove legacy GENERAL log channel

Add some more log channels instead.
This commit is contained in:
Nekotekina 2020-02-01 07:15:50 +03:00
parent efafda2650
commit d9a0619ddd
26 changed files with 269 additions and 221 deletions

View file

@ -3,6 +3,8 @@
#include <QLabel>
#include <QMessageBox>
LOG_CHANNEL(compat_log);
constexpr auto qstr = QString::fromStdString;
inline std::string sstr(const QString& _in) { return _in.toStdString(); }
@ -36,19 +38,19 @@ bool game_compatibility::ReadJSON(const QJsonObject& json_data, bool after_downl
error_message = "Server Error - Unknown Error";
break;
}
LOG_ERROR(GENERAL, "Compatibility error: { %s: return code %d }", error_message, return_code);
compat_log.error("Compatibility error: { %s: return code %d }", error_message, return_code);
Q_EMIT DownloadError(qstr(error_message) + " " + QString::number(return_code));
}
else
{
LOG_ERROR(GENERAL, "Compatibility error: { Database Error - Invalid: return code %d }", return_code);
compat_log.error("Compatibility error: { Database Error - Invalid: return code %d }", return_code);
}
return false;
}
if (!json_data["results"].isObject())
{
LOG_ERROR(GENERAL, "Compatibility error: { Database Error - No Results found }");
compat_log.error("Compatibility error: { Database Error - No Results found }");
return false;
}
@ -61,7 +63,7 @@ bool game_compatibility::ReadJSON(const QJsonObject& json_data, bool after_downl
{
if (!json_results[key].isObject())
{
LOG_ERROR(GENERAL, "Compatibility error: { Database Error - Unusable object %s }", sstr(key));
compat_log.error("Compatibility error: { Database Error - Unusable object %s }", sstr(key));
continue;
}
@ -92,20 +94,20 @@ void game_compatibility::RequestCompatibility(bool online)
if (!file.exists())
{
LOG_NOTICE(GENERAL, "Compatibility notice: { Database file not found: %s }", sstr(m_filepath));
compat_log.notice("Compatibility notice: { Database file not found: %s }", sstr(m_filepath));
return;
}
if (!file.open(QIODevice::ReadOnly))
{
LOG_ERROR(GENERAL, "Compatibility error: { Database Error - Could not read database from file: %s }", sstr(m_filepath));
compat_log.error("Compatibility error: { Database Error - Could not read database from file: %s }", sstr(m_filepath));
return;
}
QByteArray data = file.readAll();
file.close();
LOG_NOTICE(GENERAL, "Compatibility notice: { Finished reading database from file: %s }", sstr(m_filepath));
compat_log.notice("Compatibility notice: { Finished reading database from file: %s }", sstr(m_filepath));
// Create new map from database
ReadJSON(QJsonDocument::fromJson(data).object(), online);
@ -115,7 +117,7 @@ void game_compatibility::RequestCompatibility(bool online)
if (QSslSocket::supportsSsl() == false)
{
LOG_ERROR(GENERAL, "Can not retrieve the online database! Please make sure your system supports SSL. Visit our quickstart guide for more information: https://rpcs3.net/quickstart");
compat_log.error("Can not retrieve the online database! Please make sure your system supports SSL. Visit our quickstart guide for more information: https://rpcs3.net/quickstart");
const QString message = tr("Can not retrieve the online database!<br>Please make sure your system supports SSL.<br>Visit our <a href='https://rpcs3.net/quickstart'>quickstart guide</a> for more information.");
QMessageBox box(QMessageBox::Icon::Warning, tr("Warning!"), message, QMessageBox::StandardButton::Ok, nullptr);
box.setTextFormat(Qt::RichText);
@ -123,7 +125,7 @@ void game_compatibility::RequestCompatibility(bool online)
return;
}
LOG_NOTICE(GENERAL, "SSL supported! Beginning compatibility database download from: %s", sstr(m_url));
compat_log.notice("SSL supported! Beginning compatibility database download from: %s", sstr(m_url));
// Send request and wait for response
m_network_access_manager.reset(new QNetworkAccessManager());
@ -177,7 +179,7 @@ void game_compatibility::RequestCompatibility(bool online)
// We failed to retrieve a new database, therefore refresh gamelist to old state
const QString error = network_reply->errorString();
Q_EMIT DownloadError(error);
LOG_ERROR(GENERAL, "Compatibility error: { Network Error - %s }", sstr(error));
compat_log.error("Compatibility error: { Network Error - %s }", sstr(error));
}
// Clean up Progress Dialog
@ -211,7 +213,7 @@ void game_compatibility::RequestCompatibility(bool online)
m_progress_timer->stop();
}
LOG_NOTICE(GENERAL, "Compatibility notice: { Database download finished }");
compat_log.notice("Compatibility notice: { Database download finished }");
// Read data from network reply
QByteArray data = network_reply->readAll();
@ -228,19 +230,19 @@ void game_compatibility::RequestCompatibility(bool online)
if (file.exists())
{
LOG_NOTICE(GENERAL, "Compatibility notice: { Database file found: %s }", sstr(m_filepath));
compat_log.notice("Compatibility notice: { Database file found: %s }", sstr(m_filepath));
}
if (!file.open(QIODevice::WriteOnly))
{
LOG_ERROR(GENERAL, "Compatibility error: { Database Error - Could not write database to file: %s }", sstr(m_filepath));
compat_log.error("Compatibility error: { Database Error - Could not write database to file: %s }", sstr(m_filepath));
return;
}
file.write(data);
file.close();
LOG_SUCCESS(GENERAL, "Compatibility success: { Write database to file: %s }", sstr(m_filepath));
compat_log.success("Compatibility success: { Write database to file: %s }", sstr(m_filepath));
}
});