From 13a5b8f74a9024953a27e4c34740d05e9a4e3e8e Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 28 May 2019 00:38:40 +0100 Subject: make curl fetcher log debug using NSLOG stop curl fetcher logging being special case to standard error and use the fetch catagory at DEBUG level instead. The special suppress_curl_debug option is currently still obeyed --- content/fetchers/curl.c | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c index 4602f6aea..63b9ea115 100644 --- a/content/fetchers/curl.c +++ b/content/fetchers/curl.c @@ -1,7 +1,7 @@ /* - * Copyright 2006 Daniel Silverstone + * Copyright 2006-2019 Daniel Silverstone + * Copyright 2010-2018 Vincent Sanders * Copyright 2007 James Bursa - * Copyright 2003 Phil Mellor * * This file is part of NetSurf. * @@ -1282,16 +1282,28 @@ fetch_curl_progress(void *clientp, /** - * Ignore everything given to it. - * - * Used to ignore cURL debug. + * Format curl debug for nslog */ -static int fetch_curl_ignore_debug(CURL *handle, - curl_infotype type, - char *data, - size_t size, - void *userptr) +static int +fetch_curl_debug(CURL *handle, + curl_infotype type, + char *data, + size_t size, + void *userptr) { + static const char s_infotype[CURLINFO_END][3] = { + "* ", "< ", "> ", "{ ", "} ", "{ ", "} " + }; + switch(type) { + case CURLINFO_TEXT: + case CURLINFO_HEADER_OUT: + case CURLINFO_HEADER_IN: + NSLOG(fetch, DEBUG, "%s%.*s", s_infotype[type], (int)size - 1, data); + break; + + default: + break; + } return 0; } @@ -1510,14 +1522,12 @@ nserror fetch_curl_register(void) if (code != CURLE_OK) \ goto curl_easy_setopt_failed; - if (verbose_log) { - SETOPT(CURLOPT_VERBOSE, 1); - } else { - SETOPT(CURLOPT_VERBOSE, 0); - } SETOPT(CURLOPT_ERRORBUFFER, fetch_error_buffer); + SETOPT(CURLOPT_DEBUGFUNCTION, fetch_curl_debug); if (nsoption_bool(suppress_curl_debug)) { - SETOPT(CURLOPT_DEBUGFUNCTION, fetch_curl_ignore_debug); + SETOPT(CURLOPT_VERBOSE, 0); + } else { + SETOPT(CURLOPT_VERBOSE, 1); } /* Currently we explode if curl uses HTTP2, so force 1.1. */ -- cgit v1.2.3