curl: log errors

This commit is contained in:
Megamouse 2021-08-28 16:11:53 +02:00
parent 5aee8a8a81
commit 1060e93783
4 changed files with 38 additions and 14 deletions

View File

@ -584,16 +584,20 @@ int main(int argc, char** argv)
hhdr = curl_slist_append(hhdr, "Accept: application/vnd.github.v3+json");
hhdr = curl_slist_append(hhdr, "User-Agent: curl/7.37.0");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, hhdr);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, +[](const char* ptr, usz, usz size, void* json) -> usz
CURLcode err = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, hhdr);
if (err != CURLE_OK) fprintf(stderr, "curl_easy_setopt(CURLOPT_HTTPHEADER) error: %s", curl_easy_strerror(err));
err = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, +[](const char* ptr, usz, usz size, void* json) -> usz
{
static_cast<QByteArray*>(json)->append(ptr, size);
return size;
});
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buf);
if (err != CURLE_OK) fprintf(stderr, "curl_easy_setopt(CURLOPT_WRITEFUNCTION) error: %s", curl_easy_strerror(err));
err = curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buf);
if (err != CURLE_OK) fprintf(stderr, "curl_easy_setopt(CURLOPT_WRITEDATA) error: %s", curl_easy_strerror(err));
u32 page = 1;
constexpr u32 per_page = 100;
while (page <= 55)
@ -603,8 +607,19 @@ int main(int argc, char** argv)
if (!from.empty())
fmt::append(url, "&sha=%s", from);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_perform(curl);
err = curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
if (err != CURLE_OK)
{
fprintf(stderr, "curl_easy_setopt(CURLOPT_URL, %s) error: %s", url.c_str(), curl_easy_strerror(err));
break;
}
err = curl_easy_perform(curl);
if (err != CURLE_OK)
{
fprintf(stderr, "Curl error:\n%s", curl_easy_strerror(err));
break;
}
QJsonDocument info = QJsonDocument::fromJson(buf);

View File

@ -1,10 +1,13 @@
#include "curl_handle.h"
#include "Emu/system_utils.hpp"
#include "util/logs.hpp"
#ifdef _WIN32
#include "Utilities/StrUtil.h"
#endif
LOG_CHANNEL(network_log, "NET");
curl_handle::curl_handle(QObject* parent) : QObject(parent)
{
m_curl = curl_easy_init();
@ -14,7 +17,8 @@ curl_handle::curl_handle(QObject* parent) : QObject(parent)
const std::string path_to_cert = rpcs3::utils::get_exe_dir() + "cacert.pem";
const std::string ansi_path = utf8_path_to_ansi_path(path_to_cert);
curl_easy_setopt(m_curl, CURLOPT_CAINFO, ansi_path.data());
const CURLcode err = curl_easy_setopt(m_curl, CURLOPT_CAINFO, ansi_path.data());
if (err != CURLE_OK) network_log.error("curl_easy_setopt(CURLOPT_CAINFO, %s) error: %s", ansi_path, curl_easy_strerror(err));
#endif
}

View File

@ -8,7 +8,7 @@
#include "Crypto/sha256.h"
#include "util/logs.hpp"
LOG_CHANNEL(network_log, "NETWORK");
LOG_CHANNEL(network_log, "NET");
usz curl_write_cb_compat(char* ptr, usz /*size*/, usz nmemb, void* userdata)
{
@ -48,10 +48,17 @@ void downloader::start(const std::string& url, bool follow_location, bool show_p
m_curl_buf.clear();
m_curl_abort = false;
curl_easy_setopt(m_curl->get_curl(), CURLOPT_URL, url.c_str());
curl_easy_setopt(m_curl->get_curl(), CURLOPT_WRITEFUNCTION, curl_write_cb_compat);
curl_easy_setopt(m_curl->get_curl(), CURLOPT_WRITEDATA, this);
curl_easy_setopt(m_curl->get_curl(), CURLOPT_FOLLOWLOCATION, follow_location ? 1 : 0);
CURLcode err = curl_easy_setopt(m_curl->get_curl(), CURLOPT_URL, url.c_str());
if (err != CURLE_OK) network_log.error("curl_easy_setopt(CURLOPT_URL, %s) error: %s", url, curl_easy_strerror(err));
err = curl_easy_setopt(m_curl->get_curl(), CURLOPT_WRITEFUNCTION, curl_write_cb_compat);
if (err != CURLE_OK) network_log.error("curl_easy_setopt(CURLOPT_WRITEFUNCTION, curl_write_cb_compat) error: %s", curl_easy_strerror(err));
err = curl_easy_setopt(m_curl->get_curl(), CURLOPT_WRITEDATA, this);
if (err != CURLE_OK) network_log.error("curl_easy_setopt(CURLOPT_WRITEDATA) error: %s", curl_easy_strerror(err));
err = curl_easy_setopt(m_curl->get_curl(), CURLOPT_FOLLOWLOCATION, follow_location ? 1 : 0);
if (err != CURLE_OK) network_log.error("curl_easy_setopt(CURLOPT_FOLLOWLOCATION, %d) error: %s", follow_location, curl_easy_strerror(err));
m_thread = QThread::create([this]
{

View File

@ -47,8 +47,6 @@ rsx_debugger::rsx_debugger(std::shared_ptr<gui_settings> gui_settings, QWidget*
QLabel l("000000000"); // hacky way to get the lineedit to resize properly
l.setFont(mono);
QHBoxLayout* hbox_controls_addr = new QHBoxLayout();
// Controls: Breaks
QPushButton* b_break_frame = new QPushButton(tr("Frame"));
QPushButton* b_break_text = new QPushButton(tr("Texture"));