Enable some debug logging for TMS upload.
authorCarl Hetherington <cth@carlh.net>
Tue, 1 Nov 2022 20:11:40 +0000 (21:11 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 2 Nov 2022 00:17:53 +0000 (01:17 +0100)
src/lib/curl_uploader.cc
src/lib/curl_uploader.h

index 9416a17fb800cdb6b95f0dc96977adc4135cfcdb..389a5d6de50b45859401feb829713f6e793a6ccd 100644 (file)
@@ -20,6 +20,7 @@
 
 
 #include "curl_uploader.h"
+#include "dcpomatic_log.h"
 #include "exceptions.h"
 #include "config.h"
 #include "cross.h"
@@ -43,6 +44,13 @@ read_callback (void* ptr, size_t size, size_t nmemb, void* object)
 }
 
 
+static int
+curl_debug_shim (CURL* curl, curl_infotype type, char* data, size_t size, void* userp)
+{
+       return reinterpret_cast<CurlUploader*>(userp)->debug(curl, type, data, size);
+}
+
+
 CurlUploader::CurlUploader (function<void (string)> set_status, function<void (float)> set_progress)
        : Uploader (set_status, set_progress)
 {
@@ -61,6 +69,9 @@ CurlUploader::CurlUploader (function<void (string)> set_status, function<void (f
        if (!Config::instance()->tms_passive()) {
                curl_easy_setopt(_curl, CURLOPT_FTPPORT, "-");
        }
+       curl_easy_setopt(_curl, CURLOPT_VERBOSE, 1L);
+       curl_easy_setopt(_curl, CURLOPT_DEBUGFUNCTION, curl_debug_shim);
+       curl_easy_setopt(_curl, CURLOPT_DEBUGDATA, this);
 }
 
 
@@ -116,3 +127,14 @@ CurlUploader::read_callback (void* ptr, size_t size, size_t nmemb)
 
        return r;
 }
+
+
+int
+CurlUploader::debug(CURL *, curl_infotype type, char* data, size_t size)
+{
+       if (type == CURLINFO_TEXT && size > 0) {
+               LOG_GENERAL("CurlUploader: %1", string(data, size - 1));
+       }
+       return 0;
+}
+
index ea017eb8349f302b2d2c3b6fe8871a5242cc443b..4ee221f089dd1093b59062c501799603bb93e0f0 100644 (file)
@@ -31,6 +31,7 @@ public:
        ~CurlUploader ();
 
        size_t read_callback (void* ptr, size_t size, size_t nmemb);
+       int debug(CURL* curl, curl_infotype type, char* data, size_t size);
 
 protected:
        void create_directory (boost::filesystem::path directory) override;