Example: **CURL_DEBUG=http/2** means trace details about HTTP/2 handling.
+In the curl command line tool, built with `--enable-debug`, this environment
+variable adds to arguments like `--verbose`, `-vvv`. At least a single `-v`
+is needed to make the run emit trace output, but when it does, the contents
+of `CURL_DEBUG` are added and can override existing options.
+
+Example: **CURL_DEBUG=tcp,-http/2 curl -vv url** means trace protocol details,
+triggered by `-vv`, add tracing of TCP in addition and remove tracing of
+HTTP/2.
+
## CURL_DEBUG_SIZE
Fake the size returned by CURLINFO_HEADER_SIZE and CURLINFO_REQUEST_SIZE.
}
}
-CURLcode Curl_trc_opt(const char *config)
+static CURLcode trc_opt(const char *config)
{
char *token, *tok_buf, *tmp;
int lvl;
return CURLE_OK;
}
-CURLcode Curl_trc_init(void)
+CURLcode Curl_trc_opt(const char *config)
{
+ CURLcode result = config? trc_opt(config) : CURLE_OK;
#ifdef DEBUGBUILD
- /* WIP: we use the auto-init from an env var only in DEBUG builds for
- * convenience. */
- const char *config = getenv("CURL_DEBUG");
- if(config) {
- return Curl_trc_opt(config);
+ /* CURL_DEBUG can override anything */
+ if(!result) {
+ const char *dbg_config = getenv("CURL_DEBUG");
+ if(dbg_config)
+ result = trc_opt(dbg_config);
}
#endif /* DEBUGBUILD */
+ return result;
+}
+
+CURLcode Curl_trc_init(void)
+{
+#ifdef DEBUGBUILD
+ return Curl_trc_opt(NULL);
+#else
return CURLE_OK;
+#endif
}
+
#else /* defined(CURL_DISABLE_VERBOSE_STRINGS) */
CURLcode Curl_trc_init(void)