mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 16:38:32 +02:00
connectivity: refactor easy_debug_cb()
It seems nicer to me to choose a message in the switch and only print at one place.
This commit is contained in:
parent
b9f1e887c1
commit
eff5510040
1 changed files with 34 additions and 27 deletions
|
|
@ -626,44 +626,51 @@ _timeout_cb(gpointer user_data)
|
||||||
static int
|
static int
|
||||||
easy_debug_cb(CURL *handle, curl_infotype type, char *data, size_t size, void *userptr)
|
easy_debug_cb(CURL *handle, curl_infotype type, char *data, size_t size, void *userptr)
|
||||||
{
|
{
|
||||||
NMConnectivityCheckHandle *cb_data = userptr;
|
NMConnectivityCheckHandle *cb_data = userptr;
|
||||||
const char *escaped = NULL;
|
gs_free char *data_escaped = NULL;
|
||||||
gs_free char *to_free = NULL;
|
const char *msg;
|
||||||
|
gboolean print_data = FALSE;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CURLINFO_TEXT:
|
case CURLINFO_TEXT:
|
||||||
escaped = nm_utils_buf_utf8safe_escape((char *) data,
|
print_data = TRUE;
|
||||||
size,
|
msg = "== Info: ";
|
||||||
NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_CTRL,
|
break;
|
||||||
&to_free);
|
|
||||||
_LOG2T("libcurl: == Info: %s", escaped ?: "");
|
|
||||||
/* fall-through */
|
|
||||||
default: /* in case a new one is introduced to shock us */
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case CURLINFO_DATA_OUT:
|
case CURLINFO_DATA_OUT:
|
||||||
_LOG2T("libcurl => Send data");
|
msg = "=> Send data";
|
||||||
return 0;
|
break;
|
||||||
case CURLINFO_SSL_DATA_OUT:
|
case CURLINFO_SSL_DATA_OUT:
|
||||||
_LOG2T("libcurl => Send SSL data");
|
msg = "=> Send SSL data";
|
||||||
return 0;
|
break;
|
||||||
case CURLINFO_HEADER_IN:
|
case CURLINFO_HEADER_IN:
|
||||||
_LOG2T("libcurl <= Recv header");
|
msg = "<= Recv header";
|
||||||
return 0;
|
break;
|
||||||
case CURLINFO_DATA_IN:
|
case CURLINFO_DATA_IN:
|
||||||
_LOG2T("libcurl <= Recv data");
|
msg = "<= Recv data";
|
||||||
return 0;
|
break;
|
||||||
case CURLINFO_SSL_DATA_IN:
|
case CURLINFO_SSL_DATA_IN:
|
||||||
_LOG2T("libcurl <= Recv SSL data");
|
msg = "<= Recv SSL data";
|
||||||
return 0;
|
break;
|
||||||
case CURLINFO_HEADER_OUT:
|
case CURLINFO_HEADER_OUT:
|
||||||
escaped = nm_utils_buf_utf8safe_escape((char *) data,
|
print_data = TRUE;
|
||||||
size,
|
msg = "=> Send header: ";
|
||||||
NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_CTRL,
|
return 0;
|
||||||
&to_free);
|
default:
|
||||||
_LOG2T("libcurl => Send header: %s", escaped ?: "");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_LOG2T("libcurl %s%s%s%s",
|
||||||
|
msg,
|
||||||
|
NM_PRINT_FMT_QUOTED(print_data,
|
||||||
|
"[",
|
||||||
|
(data_escaped = nm_utils_buf_utf8safe_escape_cp(
|
||||||
|
data,
|
||||||
|
size,
|
||||||
|
NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_CTRL))
|
||||||
|
?: "",
|
||||||
|
"]",
|
||||||
|
""));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue