Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging: curl - write debug output through MPD log instead of curl wr… #2203

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/input/plugins/CurlInputPlugin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ input_curl_init(EventLoop &event_loop, const ConfigBlock &block)
std::chrono::seconds{1},
default_connection_timeout));

verbose = block.GetBlockValue("verbose",verbose);
verbose = block.GetBlockValue("verbose", verbose);

low_speed_limit = block.GetBlockValue("low_speed_limit", default_low_speed_limit);

Expand All @@ -436,6 +436,31 @@ input_curl_finish() noexcept
http_200_aliases = nullptr;
}

/**
* CURLOPT_DEBUGFUNCTION
*/
static int
CurlDebugToLog(CURL *handle, curl_infotype type, char *data, size_t size, void *user)
{
(void)handle;
(void)user;

switch(type) {
case CURLINFO_TEXT:
Log(LogLevel::DEBUG, curl_domain, std::string_view{data, size});
break;
case CURLINFO_HEADER_OUT:
FmtDebug(curl_domain, "Header out: {}", std::string_view{data, size});
break;
case CURLINFO_HEADER_IN:
FmtDebug(curl_domain, "Header in: {}", std::string_view{data, size});
break;
default:
break;
}
return 0;
}

template<typename I>
inline
CurlInputStream::CurlInputStream(EventLoop &event_loop, std::string_view _url,
Expand Down Expand Up @@ -513,6 +538,8 @@ CreateEasy(const char *url, struct curl_slist *headers)

easy.SetRequestHeaders(headers);

easy.SetOption(CURLOPT_DEBUGFUNCTION, CurlDebugToLog);

return easy;
}

Expand Down