-
-#ifdef HAVE_DLOG
-#include <dlog.h>
-
-extern int bDlog;
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "TBM"
-
-#define TBM_LOG_D(fmt, ...) {\
- if (bDlog) {\
- LOGD("[TBM:D] " fmt, ##__VA_ARGS__);\
- } \
- else {\
- fprintf(stderr, "[TBM:D(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__);\
- } \
-}
-
-#define TBM_LOG_I(fmt, ...) {\
- if (bDlog) {\
- LOGD("[TBM:I] " fmt, ##__VA_ARGS__);\
- } \
- else {\
- fprintf(stderr, "[TBM:I(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__);\
- } \
-}
-
-#define TBM_LOG_W(fmt, ...) {\
- if (bDlog) {\
- LOGW("[TBM:W] " fmt, ##__VA_ARGS__);\
- } \
- else {\
- fprintf(stderr, "[TBM:W(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__);\
- } \
-}
-
-#define TBM_LOG_E(fmt, ...) {\
- if (bDlog) {\
- LOGE("[TBM:E] " fmt, ##__VA_ARGS__);\
- } \
- else {\
- fprintf(stderr, "[TBM:E(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__);\
- } \
-}
-
-#define TBM_DEBUG(fmt, ...) {\
- if (bDlog) {\
- LOGE("[TBM_DEBUG] " fmt, ##__VA_ARGS__);\
- } \
- else {\
- fprintf(stderr, "[TBM:DEBUG(%d)] " fmt, getpid(), ##__VA_ARGS__);\
- } \
-}
-
-#ifdef TRACE
-#define TBM_TRACE(fmt, ...) {\
- if (bDlog) {\
- if (bTrace&0x1) LOGE("[TBM:TRACE] " fmt, ##__VA_ARGS__);\
- } \
- else {\
- if (bTrace&0x1) fprintf(stderr, "[TBM:TRACE(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__);\
- } \
-}
-#else
-#define TBM_TRACE(fmt, ...)
-#endif /* TRACE */
-
-#else
-#define TBM_LOG_D(fmt, ...) fprintf(stderr, "[TBM:D(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__)
-#define TBM_LOG_I(fmt, ...) fprintf(stderr, "[TBM:I(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__)
-#define TBM_LOG_W(fmt, ...) fprintf(stderr, "[TBM:W(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__)
-#define TBM_LOG_E(fmt, ...) fprintf(stderr, "[TBM:E(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__)
-#define TBM_DEBUG(fmt, ...) fprintf(stderr, "[TBM:DEBUG(%d)] " fmt, getpid(), ##__VA_ARGS__)
-#ifdef TRACE
-#define TBM_TRACE(fmt, ...) { if (bTrace&0x1) fprintf(stderr, "[TBM:TRACE(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__); }
-#else
-#define TBM_TRACE(fmt, ...)
-#endif /* TRACE */
-#endif /* HAVE_DLOG */
-
-/* check condition */
-#define TBM_RETURN_IF_FAIL(cond) {\
- if (!(cond)) {\
- TBM_LOG_E("'%s' failed.\n", #cond);\
- return;\
- } \
-}
-#define TBM_RETURN_VAL_IF_FAIL(cond, val) {\
- if (!(cond)) {\
- TBM_LOG_E("'%s' failed.\n", #cond);\
- return val;\
- } \
-}
-#define TBM_GOTO_VAL_IF_FAIL(cond, val) {\
- if (!(cond)) {\
- TBM_LOG_E("'%s' failed.\n", #cond);\
- goto val;\
- } \
-}