From dd8699688fc642e5a99cc58948620cc096aa74b3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 22 May 2018 02:05:41 +0300 Subject: Log libcurl errors into manaplus.log --- src/gui/windows/whoisonline.cpp | 1 + src/logger.cpp | 5 +++++ src/logger.h | 2 ++ src/net/download.cpp | 6 ++++++ src/net/download.h | 2 ++ 5 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index 30ce36220..37dbf2a89 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -568,6 +568,7 @@ int WhoIsOnline::downloadThread(void *ptr) Net::Download::addHeaders(curl); Net::Download::addProxy(curl); Net::Download::secureCurl(curl); + Net::Download::addCommonFlags(curl); // Make sure the resources2.txt and news.txt aren't cached, // in order to always get the latest version. diff --git a/src/logger.cpp b/src/logger.cpp index 4758fa026..30c371763 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -543,3 +543,8 @@ void Logger::unimplemented(const uint32_t id, id3); DebugMessageListener::distributeEvent(str); } + +FILE *Logger::getFile() const +{ + return mLogFile; +} diff --git a/src/logger.h b/src/logger.h index 96ccb88b4..269647560 100644 --- a/src/logger.h +++ b/src/logger.h @@ -212,6 +212,8 @@ class Logger final const uint32_t id2, const uint32_t id3) const; + FILE *getFile() const; + private: FILE *mLogFile; STD_VECTOR mDelayedLog; diff --git a/src/net/download.cpp b/src/net/download.cpp index c3b15cd2b..073990b07 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -343,6 +343,7 @@ int Download::downloadThread(void *ptr) addProxy(d->mCurl); secureCurl(d->mCurl); } + addCommonFlags(d->mCurl); if ((res = curl_easy_perform(d->mCurl)) != 0 && (d->mOptions.cancel == 0u) && @@ -608,6 +609,11 @@ void Download::addHeaders(CURL *const curl A_UNUSED) } #endif // LIBCURL_VERSION_NUM >= 0x071507 +void Download::addCommonFlags(CURL *const curl) +{ + curl_easy_setopt(curl, CURLOPT_STDERR, logger->getFile()); +} + void Download::prepareForm(curl_httppost **form, const std::string &fileName) { curl_httppost *lastPtr = nullptr; diff --git a/src/net/download.h b/src/net/download.h index c70118987..5b736d58d 100644 --- a/src/net/download.h +++ b/src/net/download.h @@ -106,6 +106,8 @@ class Download final static void addHeaders(CURL *const curl); + static void addCommonFlags(CURL *const curl); + static unsigned long adlerBuffer(const char *const buffer, int size); static std::string getUploadResponse() -- cgit v1.2.3-70-g09d2