File indexing completed on 2026-04-17 08:35:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef _THRIFT_TLOGGING_H_
0021 #define _THRIFT_TLOGGING_H_ 1
0022
0023 #include <thrift/thrift-config.h>
0024
0025
0026
0027
0028
0029
0030 #include <time.h>
0031
0032 #ifdef HAVE_STDINT_H
0033 #include <stdint.h>
0034 #endif
0035
0036
0037
0038
0039
0040 #define T_GLOBAL_DEBUGGING_LEVEL 0
0041
0042
0043
0044
0045
0046 #define T_GLOBAL_LOGGING_LEVEL 1
0047
0048
0049
0050
0051
0052
0053
0054
0055 #if T_GLOBAL_DEBUGGING_LEVEL > 0
0056 #define T_DEBUG(format_string, ...) \
0057 if (T_GLOBAL_DEBUGGING_LEVEL > 0) { \
0058 fprintf(stderr, "[%s,%d] " format_string " \n", __FILE__, __LINE__, ##__VA_ARGS__); \
0059 }
0060 #else
0061 #define T_DEBUG(format_string, ...)
0062 #endif
0063
0064
0065
0066
0067
0068
0069 #if T_GLOBAL_DEBUGGING_LEVEL > 0
0070 #define T_DEBUG_T(format_string, ...) \
0071 { \
0072 if (T_GLOBAL_DEBUGGING_LEVEL > 0) { \
0073 time_t now; \
0074 char dbgtime[26]; \
0075 time(&now); \
0076 THRIFT_CTIME_R(&now, dbgtime); \
0077 dbgtime[24] = '\0'; \
0078 fprintf(stderr, \
0079 "[%s,%d] [%s] " format_string " \n", \
0080 __FILE__, \
0081 __LINE__, \
0082 dbgtime, \
0083 ##__VA_ARGS__); \
0084 } \
0085 }
0086 #else
0087 #define T_DEBUG_T(format_string, ...)
0088 #endif
0089
0090
0091
0092
0093
0094
0095
0096
0097 #define T_DEBUG_L(level, format_string, ...) \
0098 if ((level) > 0) { \
0099 fprintf(stderr, "[%s,%d] " format_string " \n", __FILE__, __LINE__, ##__VA_ARGS__); \
0100 }
0101
0102
0103
0104
0105
0106
0107 #define T_ERROR(format_string, ...) \
0108 { \
0109 time_t now; \
0110 char dbgtime[26]; \
0111 time(&now); \
0112 THRIFT_CTIME_R(&now, dbgtime); \
0113 dbgtime[24] = '\0'; \
0114 fprintf(stderr, \
0115 "[%s,%d] [%s] ERROR: " format_string " \n", \
0116 __FILE__, \
0117 __LINE__, \
0118 dbgtime, \
0119 ##__VA_ARGS__); \
0120 }
0121
0122
0123
0124
0125
0126
0127
0128 #define T_ERROR_ABORT(format_string, ...) \
0129 { \
0130 time_t now; \
0131 char dbgtime[26]; \
0132 time(&now); \
0133 THRIFT_CTIME_R(&now, dbgtime); \
0134 dbgtime[24] = '\0'; \
0135 fprintf(stderr, \
0136 "[%s,%d] [%s] ERROR: Going to abort " format_string " \n", \
0137 __FILE__, \
0138 __LINE__, \
0139 dbgtime, \
0140 ##__VA_ARGS__); \
0141 exit(1); \
0142 }
0143
0144
0145
0146
0147
0148
0149 #if T_GLOBAL_LOGGING_LEVEL > 0
0150 #define T_LOG_OPER(format_string, ...) \
0151 { \
0152 if (T_GLOBAL_LOGGING_LEVEL > 0) { \
0153 time_t now; \
0154 char dbgtime[26]; \
0155 time(&now); \
0156 THRIFT_CTIME_R(&now, dbgtime); \
0157 dbgtime[24] = '\0'; \
0158 fprintf(stderr, "[%s] " format_string " \n", dbgtime, ##__VA_ARGS__); \
0159 } \
0160 }
0161 #else
0162 #define T_LOG_OPER(format_string, ...)
0163 #endif
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174 #if T_GLOBAL_DEBUG_VIRTUAL > 1
0175 #define T_VIRTUAL_CALL() ::apache::thrift::profile_virtual_call(typeid(*this))
0176 #define T_GENERIC_PROTOCOL(template_class, generic_prot, specific_prot) \
0177 do { \
0178 if (!(specific_prot)) { \
0179 ::apache::thrift::profile_generic_protocol(typeid(*template_class), typeid(*generic_prot)); \
0180 } \
0181 } while (0)
0182 #elif T_GLOBAL_DEBUG_VIRTUAL == 1
0183 #define T_VIRTUAL_CALL() fprintf(stderr, "[%s,%d] virtual call\n", __FILE__, __LINE__)
0184 #define T_GENERIC_PROTOCOL(template_class, generic_prot, specific_prot) \
0185 do { \
0186 if (!(specific_prot)) { \
0187 fprintf(stderr, "[%s,%d] failed to cast to specific protocol type\n", __FILE__, __LINE__); \
0188 } \
0189 } while (0)
0190 #else
0191 #define T_VIRTUAL_CALL()
0192 #define T_GENERIC_PROTOCOL(template_class, generic_prot, specific_prot)
0193 #endif
0194
0195 #endif