• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_global_trace
5Section: 3
6Source: libcurl
7See-also:
8  - curl_global_init (3)
9  - libcurl (3)
10Protocol:
11  - All
12Added-in: 8.3
13---
14
15# NAME
16
17curl_global_trace - log configuration
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_global_trace(const char *config);
25~~~
26
27# DESCRIPTION
28
29This function configures the logging behavior to make some parts of curl more
30verbose or silent than others.
31
32This function may be called during the initialization phase of a program. It
33does not have to be. It can be called several times even, possibly overwriting
34settings of previous calls.
35
36Calling this function after transfers have been started is undefined. On some
37platforms/architectures it might take effect, on others not.
38
39This function is thread-safe since libcurl 8.3.0 if curl_version_info(3) has
40the CURL_VERSION_THREADSAFE feature bit set (most platforms).
41
42If this is not thread-safe, you must not call this function when any other
43thread in the program (i.e. a thread sharing the same memory) is running. This
44does not just mean no other thread that is using libcurl. Because
45curl_global_init(3) may call functions of other libraries that are similarly
46thread unsafe, it could conflict with any other thread that uses these other
47libraries.
48
49If you are initializing libcurl from a Windows DLL you should not initialize
50it from *DllMain* or a static initializer because Windows holds the loader
51lock during that time and it could cause a deadlock.
52
53The *config* string is a list of comma-separated component names. Names are
54case-insensitive and unknown names are ignored. The special name "all" applies
55to all components. Names may be prefixed with '+' or '-' to enable or disable
56detailed logging for a component.
57
58The list of component names is not part of curl's public API. Names may be
59added or disappear in future versions of libcurl. Since unknown names are
60silently ignored, outdated log configurations does not cause errors when
61upgrading libcurl. Given that, some names can be expected to be fairly stable
62and are listed below for easy reference.
63
64Note that log configuration applies only to transfers where debug logging is
65enabled. See CURLOPT_VERBOSE(3) or CURLOPT_DEBUGFUNCTION(3) on how to control
66that.
67
68# TRACE COMPONENTS
69
70## `tcp`
71
72Tracing of TCP socket handling: connect, sends, receives.
73
74## `ssl`
75
76Tracing of SSL/TLS operations, whichever SSL backend is used in your build.
77
78## `ftp`
79
80Tracing of FTP operations when this protocol is enabled in your build.
81
82## `http/2`
83
84Details about HTTP/2 handling: frames, events, I/O, etc.
85
86## `http/3`
87
88Details about HTTP/3 handling: connect, frames, events, I/O etc.
89
90## `http-proxy`
91
92Involved when transfers are tunneled through an HTTP proxy. "h1-proxy" or
93"h2-proxy" are also involved, depending on the HTTP version negotiated with
94the proxy.
95
96In order to find out all components involved in a transfer, run it with "all"
97configured. You can then see all names involved in your libcurl version in the
98trace.
99
100## `doh`
101
102Tracing of DNS-over-HTTP operations to resolve hostnames.
103
104## `read`
105
106Traces reading of upload data from the application in order to send it to the server.
107
108## `ssls`
109
110Tracing of SSL Session handling, e.g. caching/import/export.
111
112## `smtp`
113
114Tracing of SMTP operations when this protocol is enabled in your build.
115
116## `write`
117
118Traces writing of download data, received from the server, to the application.
119
120## `ws`
121
122Tracing of WebSocket operations when this protocol is enabled in your build.
123
124# TRACE GROUPS
125
126Besides the specific component names there are the following group names
127defined:
128
129## `all`
130
131## `network`
132
133All components involved in bare network I/O, including the SSL layer.
134
135All components that your libcurl is built with.
136
137## `protocol`
138
139All components involved in transfer protocols, such as 'ftp' and 'http/2'.
140
141## `proxy`
142
143All components involved in use of proxies.
144
145# %PROTOCOLS%
146
147# EXAMPLE
148
149~~~c
150int main(void)
151{
152  /* log details of HTTP/2 and SSL handling */
153  curl_global_trace("http/2,ssl");
154
155  /* log all details, except SSL handling */
156  curl_global_trace("all,-ssl");
157}
158~~~
159
160Below is a trace sample where "http/2" was configured. The trace output
161of an enabled component appears at the beginning in brackets.
162~~~
163* [HTTP/2] [h2sid=1] cf_send(len=96) submit https://example.com/
164...
165* [HTTP/2] [h2sid=1] FRAME[HEADERS]
166* [HTTP/2] [h2sid=1] 249 header bytes
167...
168~~~
169
170# %AVAILABILITY%
171
172# RETURN VALUE
173
174If this function returns non-zero, something went wrong and the configuration
175may not have any effects or may only been applied partially.
176