debug.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /******************************************************************
  2. ** Copyright (c) 2007-2008 Wuhan Mozit Technology Co., Ltd .
  3. ** FileName: debug.h
  4. ** Author: BigHead
  5. ** Mail: jsrenyw@sohu.com
  6. ** Date : 2007-5-31 下午07:19:16
  7. ** Version: 2007-5-31
  8. ** File Description:ALL the DEBUG ON/OFFs define here!
  9. ******************************************************************/
  10. #ifndef DEBUG_H_
  11. #define DEBUG_H_
  12. /* 复制全部接收到的数据*/
  13. //#define DEBUG_DUP_RECV
  14. #ifdef DEBUG_DUP_RECV
  15. #define DEBUG_DUP_RECV_FILE "/tmp/myDebug" //镜像数据的文件名前缀
  16. #endif /* */
  17. /* network.c 2006-11-2 13:04:15 */
  18. //#define DEBUG_NETWORK
  19. /* main.c 2006-11-2 13:04:26 */
  20. #define DEBUG
  21. #define DEBUG_HALL_LOGIN
  22. //#define DEBUG_HALL
  23. //#define DEBUG_MAIN
  24. //#define DEBUG_SEND
  25. //#define DEBUG_RECV
  26. //#define DEBUG_PRE
  27. /* db.c 2006-11-12 15:03:16 */
  28. #define DEBUG_DB_PARAM
  29. /* sdk.c 2006-11-2 13:04:33 */
  30. #define DEBUG_SDK_PARAM
  31. #define DEBUG_SDK_RETURN
  32. /* Time Used Debug 2006-12-19 20:01:03 */
  33. #define DEBUG_TIME
  34. /* test.h 2006-11-3 14:48:56 */
  35. #define DEBUG_TEST_H
  36. /* ASSERT, add by YellowBug 2013-1-7 */
  37. #define ASSERT
  38. #ifdef ASSERT
  39. #include <assert.h>
  40. #else
  41. #define assert(exp)
  42. #endif
  43. /* 调试相关宏 */
  44. #define DEBUG_ON
  45. #define LOG_ON
  46. #define ERRLOG_ON
  47. #if defined(DEBUG_ON) || defined(LOG_ON) || defined(ERRLOG_ON)
  48. #include <stdio.h>
  49. #define _XOPEN_SOURCE
  50. #define __USE_XOPEN
  51. #include <time.h>
  52. //获取系统时间年月日 时分秒
  53. // char* GetCurrentTimes(void);
  54. //static char str[64] = { 0 };
  55. #endif
  56. //打印调试信息宏 add by YellowBug 2012-7-17
  57. #ifdef DEBUG_ON
  58. #define debug(...) \
  59. do \
  60. { \
  61. fprintf(stdout, "D/(%s,%d,%s) ", __FILE__, __LINE__, __FUNCTION__); \
  62. fprintf(stdout, __VA_ARGS__); \
  63. fflush(stdout); \
  64. } while (0)
  65. #else /* */
  66. #define debug(...)
  67. #endif /* #ifdef DEBUG_ON */
  68. //打印日志宏(必要信息) add by YellowBug 2012-7-17
  69. #ifdef LOG_ON
  70. #define log(...) \
  71. do \
  72. { \
  73. char str[64] = { 0 }; \
  74. time_t t = time(0); \
  75. strftime(str, sizeof(str), "%Y%m%d %H:%M:%S", localtime(&t)); \
  76. fprintf(stdout, "I/ %s ", str); \
  77. fprintf(stdout, __VA_ARGS__); \
  78. fflush(stdout); \
  79. } while (0)
  80. #else /* */
  81. #define log(...)
  82. #endif //OEPN_LOG
  83. // 答应错误日志
  84. #ifdef ERRLOG_ON
  85. #define elog(...) \
  86. do \
  87. { \
  88. fprintf(stdout, "E/(%s,%d,%s) ", __FILE__, __LINE__, __FUNCTION__); \
  89. fprintf(stdout, __VA_ARGS__); \
  90. fflush(stdout); \
  91. } while (0)
  92. #else
  93. #define elog(...)
  94. #endif
  95. // //获取系统时间年月日 时分秒
  96. // char* GetCurrentTimes(void)
  97. // {
  98. // time_t t = time(0);
  99. // static char str[64] = { 0 };
  100. // strftime(str, sizeof(str), "%Y%m%d %H:%M:%S", localtime(&t));
  101. // return str;
  102. // }
  103. #endif /* DEBUG_H_ */
  104. /* END */