#ifndef _LBUG_THRIFT_TLOGGING_H_
#define _LBUG_THRIFT_TLOGGING_H_ 1
#include "thrift-config.h"
#include <time.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#define T_GLOBAL_DEBUGGING_LEVEL 0
#define T_GLOBAL_LOGGING_LEVEL 0
#if T_GLOBAL_DEBUGGING_LEVEL > 0
#define T_DEBUG(format_string, ...) \
if (T_GLOBAL_DEBUGGING_LEVEL > 0) { \
fprintf(stderr, "[%s,%d] " format_string " \n", __FILE__, __LINE__, ##__VA_ARGS__); \
}
#else
#define T_DEBUG(format_string, ...)
#endif
#if T_GLOBAL_DEBUGGING_LEVEL > 0
#define T_DEBUG_T(format_string, ...) \
{ \
if (T_GLOBAL_DEBUGGING_LEVEL > 0) { \
time_t now; \
char dbgtime[26]; \
time(&now); \
THRIFT_CTIME_R(&now, dbgtime); \
dbgtime[24] = '\0'; \
fprintf(stderr, \
"[%s,%d] [%s] " format_string " \n", \
__FILE__, \
__LINE__, \
dbgtime, \
##__VA_ARGS__); \
} \
}
#else
#define T_DEBUG_T(format_string, ...)
#endif
#if T_GLOBAL_LOGGING_LEVEL > 0
#define T_LOG_OPER(format_string, ...) \
{ \
if (T_GLOBAL_LOGGING_LEVEL > 0) { \
time_t now; \
char dbgtime[26]; \
time(&now); \
THRIFT_CTIME_R(&now, dbgtime); \
dbgtime[24] = '\0'; \
fprintf(stderr, "[%s] " format_string " \n", dbgtime, ##__VA_ARGS__); \
} \
}
#else
#define T_LOG_OPER(format_string, ...)
#endif
#if T_GLOBAL_DEBUG_VIRTUAL > 1
#define T_VIRTUAL_CALL() ::lbug_apache::thrift::profile_virtual_call(typeid(*this))
#define T_GENERIC_PROTOCOL(template_class, generic_prot, specific_prot) \
do { \
if (!(specific_prot)) { \
::lbug_apache::thrift::profile_generic_protocol(typeid(*template_class), typeid(*generic_prot)); \
} \
} while (0)
#elif T_GLOBAL_DEBUG_VIRTUAL == 1
#define T_VIRTUAL_CALL() fprintf(stderr, "[%s,%d] virtual call\n", __FILE__, __LINE__)
#define T_GENERIC_PROTOCOL(template_class, generic_prot, specific_prot) \
do { \
if (!(specific_prot)) { \
fprintf(stderr, "[%s,%d] failed to cast to specific protocol type\n", __FILE__, __LINE__); \
} \
} while (0)
#else
#define T_VIRTUAL_CALL()
#define T_GENERIC_PROTOCOL(template_class, generic_prot, specific_prot)
#endif
#endif