@@ -11,7 +11,10 @@ struct trace_key {
11
11
unsigned int need_close : 1 ;
12
12
};
13
13
14
+ extern struct trace_key trace_default_key ;
15
+
14
16
#define TRACE_KEY_INIT (name ) { "GIT_TRACE_" #name, 0, 0, 0 }
17
+ extern struct trace_key trace_perf_key ;
15
18
16
19
extern void trace_repo_setup (const char * prefix );
17
20
extern int trace_want (struct trace_key * key );
@@ -77,24 +80,42 @@ extern void trace_performance_since(uint64_t start, const char *format, ...);
77
80
* comma, but this is non-standard.
78
81
*/
79
82
80
- #define trace_printf (...) \
81
- trace_printf_key_fl(TRACE_CONTEXT, __LINE__, NULL, __VA_ARGS__)
82
-
83
- #define trace_printf_key (key , ...) \
84
- trace_printf_key_fl(TRACE_CONTEXT, __LINE__, key, __VA_ARGS__)
85
-
86
- #define trace_argv_printf (argv , ...) \
87
- trace_argv_printf_fl(TRACE_CONTEXT, __LINE__, argv, __VA_ARGS__)
88
-
89
- #define trace_strbuf (key , data ) \
90
- trace_strbuf_fl(TRACE_CONTEXT, __LINE__, key, data)
91
-
92
- #define trace_performance (nanos , ...) \
93
- trace_performance_fl(TRACE_CONTEXT, __LINE__, nanos, __VA_ARGS__)
94
-
95
- #define trace_performance_since (start , ...) \
96
- trace_performance_fl(TRACE_CONTEXT, __LINE__, getnanotime() - (start), \
97
- __VA_ARGS__)
83
+ #define trace_printf_key (key , ...) \
84
+ do { \
85
+ if (trace_pass_fl(key)) \
86
+ trace_printf_key_fl(TRACE_CONTEXT, __LINE__, key, \
87
+ __VA_ARGS__); \
88
+ } while (0)
89
+
90
+ #define trace_printf (...) trace_printf_key(&trace_default_key, __VA_ARGS__)
91
+
92
+ #define trace_argv_printf (argv , ...) \
93
+ do { \
94
+ if (trace_pass_fl(&trace_default_key)) \
95
+ trace_argv_printf_fl(TRACE_CONTEXT, __LINE__, \
96
+ argv, __VA_ARGS__); \
97
+ } while (0)
98
+
99
+ #define trace_strbuf (key , data ) \
100
+ do { \
101
+ if (trace_pass_fl(key)) \
102
+ trace_strbuf_fl(TRACE_CONTEXT, __LINE__, key, data);\
103
+ } while (0)
104
+
105
+ #define trace_performance (nanos , ...) \
106
+ do { \
107
+ if (trace_pass_fl(&trace_perf_key)) \
108
+ trace_performance_fl(TRACE_CONTEXT, __LINE__, nanos,\
109
+ __VA_ARGS__); \
110
+ } while (0)
111
+
112
+ #define trace_performance_since (start , ...) \
113
+ do { \
114
+ if (trace_pass_fl(&trace_perf_key)) \
115
+ trace_performance_fl(TRACE_CONTEXT, __LINE__, \
116
+ getnanotime() - (start), \
117
+ __VA_ARGS__); \
118
+ } while (0)
98
119
99
120
/* backend functions, use non-*fl macros instead */
100
121
__attribute__((format (printf , 4 , 5 )))
@@ -108,6 +129,10 @@ extern void trace_strbuf_fl(const char *file, int line, struct trace_key *key,
108
129
__attribute__((format (printf , 4 , 5 )))
109
130
extern void trace_performance_fl (const char * file , int line ,
110
131
uint64_t nanos , const char * fmt , ...);
132
+ static inline int trace_pass_fl (struct trace_key * key )
133
+ {
134
+ return key -> fd || !key -> initialized ;
135
+ }
111
136
112
137
#endif /* HAVE_VARIADIC_MACROS */
113
138
0 commit comments