1 | #ifndef HEADER_CURL_TRC_H
|
---|
2 | #define HEADER_CURL_TRC_H
|
---|
3 | /***************************************************************************
|
---|
4 | * _ _ ____ _
|
---|
5 | * Project ___| | | | _ \| |
|
---|
6 | * / __| | | | |_) | |
|
---|
7 | * | (__| |_| | _ <| |___
|
---|
8 | * \___|\___/|_| \_\_____|
|
---|
9 | *
|
---|
10 | * Copyright (C) Daniel Stenberg, <[email protected]>, et al.
|
---|
11 | *
|
---|
12 | * This software is licensed as described in the file COPYING, which
|
---|
13 | * you should have received as part of this distribution. The terms
|
---|
14 | * are also available at https://curl.se/docs/copyright.html.
|
---|
15 | *
|
---|
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
---|
17 | * copies of the Software, and permit persons to whom the Software is
|
---|
18 | * furnished to do so, under the terms of the COPYING file.
|
---|
19 | *
|
---|
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
---|
21 | * KIND, either express or implied.
|
---|
22 | *
|
---|
23 | * SPDX-License-Identifier: curl
|
---|
24 | *
|
---|
25 | ***************************************************************************/
|
---|
26 |
|
---|
27 | struct Curl_easy;
|
---|
28 | struct Curl_cfilter;
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * Init logging, return != 0 on failure.
|
---|
32 | */
|
---|
33 | CURLcode Curl_trc_init(void);
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * Configure tracing. May be called several times during global
|
---|
37 | * initialization. Later calls may not take effect.
|
---|
38 | *
|
---|
39 | * Configuration format supported:
|
---|
40 | * - comma-separated list of component names to enable logging on.
|
---|
41 | * E.g. 'http/2,ssl'. Unknown names are ignored. Names are compared
|
---|
42 | * case-insensitive.
|
---|
43 | * - component 'all' applies to all known log components
|
---|
44 | * - prefixing a component with '+' or '-' will en-/disable logging for
|
---|
45 | * that component
|
---|
46 | * Example: 'all,-ssl' would enable logging for all components but the
|
---|
47 | * SSL filters.
|
---|
48 | *
|
---|
49 | * @param config configuration string
|
---|
50 | */
|
---|
51 | CURLcode Curl_trc_opt(const char *config);
|
---|
52 |
|
---|
53 | /* the function used to output verbose information */
|
---|
54 | void Curl_debug(struct Curl_easy *data, curl_infotype type,
|
---|
55 | char *ptr, size_t size);
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Output an informational message when transfer's verbose logging is enabled.
|
---|
59 | */
|
---|
60 | void Curl_infof(struct Curl_easy *data,
|
---|
61 | #if defined(__GNUC__) && !defined(printf) && \
|
---|
62 | defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
|
---|
63 | !defined(__MINGW32__)
|
---|
64 | const char *fmt, ...)
|
---|
65 | __attribute__((format(printf, 2, 3)));
|
---|
66 | #else
|
---|
67 | const char *fmt, ...);
|
---|
68 | #endif
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * Output a failure message on registered callbacks for transfer.
|
---|
72 | */
|
---|
73 | void Curl_failf(struct Curl_easy *data,
|
---|
74 | #if defined(__GNUC__) && !defined(printf) && \
|
---|
75 | defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
|
---|
76 | !defined(__MINGW32__)
|
---|
77 | const char *fmt, ...)
|
---|
78 | __attribute__((format(printf, 2, 3)));
|
---|
79 | #else
|
---|
80 | const char *fmt, ...);
|
---|
81 | #endif
|
---|
82 |
|
---|
83 | #define failf Curl_failf
|
---|
84 |
|
---|
85 | /**
|
---|
86 | * Output an informational message when both transfer's verbose logging
|
---|
87 | * and connection filters verbose logging are enabled.
|
---|
88 | */
|
---|
89 | void Curl_trc_cf_infof(struct Curl_easy *data, struct Curl_cfilter *cf,
|
---|
90 | #if defined(__GNUC__) && !defined(printf) && \
|
---|
91 | defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
|
---|
92 | !defined(__MINGW32__)
|
---|
93 | const char *fmt, ...)
|
---|
94 | __attribute__((format(printf, 3, 4)));
|
---|
95 | #else
|
---|
96 | const char *fmt, ...);
|
---|
97 | #endif
|
---|
98 |
|
---|
99 | #define CURL_LOG_LVL_NONE 0
|
---|
100 | #define CURL_LOG_LVL_INFO 1
|
---|
101 |
|
---|
102 |
|
---|
103 | #if !defined(CURL_DISABLE_VERBOSE_STRINGS)
|
---|
104 | /* informational messages enabled */
|
---|
105 |
|
---|
106 | #define Curl_trc_is_verbose(data) ((data) && (data)->set.verbose)
|
---|
107 | #define Curl_trc_cf_is_verbose(cf, data) \
|
---|
108 | ((data) && (data)->set.verbose && \
|
---|
109 | (cf) && (cf)->cft->log_level >= CURL_LOG_LVL_INFO)
|
---|
110 |
|
---|
111 | /* explainer: we have some mix configuration and werror settings
|
---|
112 | * that define HAVE_VARIADIC_MACROS_C99 even though C89 is enforced
|
---|
113 | * on gnuc and some other compiler. Need to treat carefully.
|
---|
114 | */
|
---|
115 | #if defined(HAVE_VARIADIC_MACROS_C99) && \
|
---|
116 | defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
|
---|
117 |
|
---|
118 | #define infof(data, ...) \
|
---|
119 | do { if(Curl_trc_is_verbose(data)) \
|
---|
120 | Curl_infof(data, __VA_ARGS__); } while(0)
|
---|
121 | #define CURL_TRC_CF(data, cf, ...) \
|
---|
122 | do { if(Curl_trc_cf_is_verbose(cf, data)) \
|
---|
123 | Curl_trc_cf_infof(data, cf, __VA_ARGS__); } while(0)
|
---|
124 |
|
---|
125 | #else /* no variadic macro args */
|
---|
126 | #define infof Curl_infof
|
---|
127 | #define CURL_TRC_CF Curl_trc_cf_infof
|
---|
128 | #endif /* variadic macro args */
|
---|
129 |
|
---|
130 | #else /* !CURL_DISABLE_VERBOSE_STRINGS */
|
---|
131 | /* All informational messages are not compiled in for size savings */
|
---|
132 |
|
---|
133 | #define Curl_trc_is_verbose(d) ((void)(d), FALSE)
|
---|
134 | #define Curl_trc_cf_is_verbose(x,y) ((void)(x), (void)(y), FALSE)
|
---|
135 |
|
---|
136 | #if defined(HAVE_VARIADIC_MACROS_C99)
|
---|
137 | #define infof(...) Curl_nop_stmt
|
---|
138 | #define CURL_TRC_CF(...) Curl_nop_stmt
|
---|
139 | #define Curl_trc_cf_infof(...) Curl_nop_stmt
|
---|
140 | #elif defined(HAVE_VARIADIC_MACROS_GCC)
|
---|
141 | #define infof(x...) Curl_nop_stmt
|
---|
142 | #define CURL_TRC_CF(x...) Curl_nop_stmt
|
---|
143 | #define Curl_trc_cf_infof(x...) Curl_nop_stmt
|
---|
144 | #else
|
---|
145 | #error "missing VARIADIC macro define, fix and rebuild!"
|
---|
146 | #endif
|
---|
147 |
|
---|
148 | #endif /* CURL_DISABLE_VERBOSE_STRINGS */
|
---|
149 |
|
---|
150 | #endif /* HEADER_CURL_TRC_H */
|
---|