| 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 |
|
| 26 |
#include "src/core/lib/debug/trace.h" |
| 27 |
|
| 28 |
extern grpc_core::TraceFlag grpc_api_trace; |
| 29 |
|
| 30 |
/* Provide unwrapping macros because we're in C89 and variadic macros weren't |
| 31 |
introduced until C99... */ |
| 32 |
#define GRPC_API_TRACE_UNWRAP0() |
| 33 |
#define GRPC_API_TRACE_UNWRAP1(a) , a |
| 34 |
#define GRPC_API_TRACE_UNWRAP2(a, b) , a, b |
| 35 |
#define GRPC_API_TRACE_UNWRAP3(a, b, c) , a, b, c |
| 36 |
#define GRPC_API_TRACE_UNWRAP4(a, b, c, d) , a, b, c, d |
| 37 |
#define GRPC_API_TRACE_UNWRAP5(a, b, c, d, e) , a, b, c, d, e |
| 38 |
#define GRPC_API_TRACE_UNWRAP6(a, b, c, d, e, f) , a, b, c, d, e, f |
| 39 |
#define GRPC_API_TRACE_UNWRAP7(a, b, c, d, e, f, g) , a, b, c, d, e, f, g |
| 40 |
#define GRPC_API_TRACE_UNWRAP8(a, b, c, d, e, f, g, h) , a, b, c, d, e, f, g, h |
| 41 |
#define GRPC_API_TRACE_UNWRAP9(a, b, c, d, e, f, g, h, i) \ |
| 42 |
, a, b, c, d, e, f, g, h, i |
| 43 |
#define GRPC_API_TRACE_UNWRAP10(a, b, c, d, e, f, g, h, i, j) \ |
| 44 |
, a, b, c, d, e, f, g, h, i, j |
| 45 |
|
| 46 |
/* Due to the limitations of C89's preprocessor, the arity of the var-arg list |
| 47 |
'nargs' must be specified. */ |
| 48 |
#define GRPC_API_TRACE(fmt, nargs, args) \ |
| 49 |
if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace)) { \ |
| 50 |
gpr_log(GPR_INFO, fmt GRPC_API_TRACE_UNWRAP##nargs args); \ |
| 51 |
} |
| 52 |
|
| 53 |
#endif /* GRPC_CORE_LIB_SURFACE_API_TRACE_H */ |