1 /* 2 * 3 * Copyright 2015 gRPC authors. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 19 #ifndef GRPC_CORE_LIB_SURFACE_API_TRACE_H 20 #define GRPC_CORE_LIB_SURFACE_API_TRACE_H 21 22 #include <grpc/support/port_platform.h> 23 24 #include <grpc/support/log.h> 25 #include "src/core/lib/debug/trace.h" 26 27 extern grpc_core::TraceFlag grpc_api_trace; 28 29 /* Provide unwrapping macros because we're in C89 and variadic macros weren't 30 introduced until C99... */ 31 #define GRPC_API_TRACE_UNWRAP0() 32 #define GRPC_API_TRACE_UNWRAP1(a) , a 33 #define GRPC_API_TRACE_UNWRAP2(a, b) , a, b 34 #define GRPC_API_TRACE_UNWRAP3(a, b, c) , a, b, c 35 #define GRPC_API_TRACE_UNWRAP4(a, b, c, d) , a, b, c, d 36 #define GRPC_API_TRACE_UNWRAP5(a, b, c, d, e) , a, b, c, d, e 37 #define GRPC_API_TRACE_UNWRAP6(a, b, c, d, e, f) , a, b, c, d, e, f 38 #define GRPC_API_TRACE_UNWRAP7(a, b, c, d, e, f, g) , a, b, c, d, e, f, g 39 #define GRPC_API_TRACE_UNWRAP8(a, b, c, d, e, f, g, h) , a, b, c, d, e, f, g, h 40 #define GRPC_API_TRACE_UNWRAP9(a, b, c, d, e, f, g, h, i) \ 41 , a, b, c, d, e, f, g, h, i 42 #define GRPC_API_TRACE_UNWRAP10(a, b, c, d, e, f, g, h, i, j) \ 43 , a, b, c, d, e, f, g, h, i, j 44 45 /* Due to the limitations of C89's preprocessor, the arity of the var-arg list 46 'nargs' must be specified. */ 47 #define GRPC_API_TRACE(fmt, nargs, args) \ 48 if (grpc_api_trace.enabled()) { \ 49 gpr_log(GPR_INFO, fmt GRPC_API_TRACE_UNWRAP##nargs args); \ 50 } 51 52 #endif /* GRPC_CORE_LIB_SURFACE_API_TRACE_H */ 53