PageRenderTime 25ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/oyranos-0.4.0/oyranos_debug.h

#
C Header | 147 lines | 105 code | 24 blank | 18 comment | 35 complexity | 89943fd7eaf701f620c15df778c8c2fd MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.0, GPL-2.0
  1. /** @file oyranos_debug.h
  2. *
  3. * Oyranos is an open source Colour Management System
  4. *
  5. * @par Copyright:
  6. * 2005-2009 (C) Kai-Uwe Behrmann
  7. *
  8. * @brief internal helpers
  9. * @internal
  10. * @author Kai-Uwe Behrmann <ku.b@gmx.de>
  11. * @par License:
  12. * new BSD <http://www.opensource.org/licenses/bsd-license.php>
  13. * @since 2005/31/01
  14. *
  15. * Do not use in non Oyranos projects.
  16. */
  17. #ifndef OYRANOS_DEBUG_H
  18. #define OYRANOS_DEBUG_H
  19. #include <time.h>
  20. #include "config.h"
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif /* __cplusplus */
  24. /** debugging variable - set 0 to off (default), set 1 to switch debugging on */
  25. extern clock_t oyranos_clock_;
  26. extern int level_PROG;
  27. double oyClock ( );
  28. double oySeconds ( );
  29. #if defined(__GNUC__)
  30. # define OY_DBG_FORMAT_ "%s:%d %s() "
  31. # define OY_DBG_ARGS_ strrchr(__FILE__,'/') ? strrchr(__FILE__,'/')+1 : __FILE__,__LINE__,__func__
  32. #else
  33. # define OY_DBG_FORMAT_ "%s:%d "
  34. # define OY_DBG_ARGS_ strrchr(__FILE__,'/') ? strrchr(__FILE__,'/')+1 : __FILE__,__LINE__
  35. #endif
  36. #if defined(OY_CONFIG_H)
  37. /* Debug system */
  38. #define DBG_UHR_ (double)clock()/(double)CLOCKS_PER_SEC
  39. #if DEBUG == 1
  40. #define DBG oyMessageFunc_p(oyMSG_DBG,0,OY_DBG_FORMAT_, OY_DBG_ARGS_);
  41. #define DBG_S(txt) oyMessageFunc_p(oyMSG_DBG,0,OY_DBG_FORMAT_ "%s", OY_DBG_ARGS_,txt);
  42. #define DBG1_S(format,arg) oyMessageFunc_p( oyMSG_DBG,0,OY_DBG_FORMAT_ format,OY_DBG_ARGS_,arg);
  43. #define DBG2_S(format,arg,arg2) oyMessageFunc_p( oyMSG_DBG,0,OY_DBG_FORMAT_ format,OY_DBG_ARGS_,arg,arg2);
  44. #define DBG3_S(format,arg,arg2,arg3) oyMessageFunc_p( oyMSG_DBG,0,OY_DBG_FORMAT_ format,OY_DBG_ARGS_,arg,arg2,arg3);
  45. #define DBG4_S(format,arg,arg2,arg3,arg4) oyMessageFunc_p( oyMSG_DBG,0,OY_DBG_FORMAT_ format, OY_DBG_ARGS_,arg,arg2,arg3,arg4);
  46. #define DBG5_S(format,arg,arg2,arg3,arg4,arg5) oyMessageFunc_p( oyMSG_DBG,0,OY_DBG_FORMAT_ format, OY_DBG_ARGS_,arg,arg2,arg3,arg4,arg5);
  47. #define DBG6_S(format,arg,arg2,arg3,arg4,arg5,arg6) oyMessageFunc_p( oyMSG_DBG,0,OY_DBG_FORMAT_ format, OY_DBG_ARGS_,arg,arg2,arg3,arg4,arg5,arg6);
  48. #define DBG_V(var) oyMessageFunc_p(oyMSG_DBG,0,OY_DBG_FORMAT_ #var ": %d", OY_DBG_ARGS_,(int)var);
  49. #define DBG_START {++level_PROG; oyMessageFunc_p( oyMSG_DBG,0,"Start: " OY_DBG_FORMAT_, OY_DBG_ARGS_ );}
  50. #define DBG_ENDE {oyMessageFunc_p( oyMSG_DBG,0," End: " OY_DBG_FORMAT_, OY_DBG_ARGS_ ); --level_PROG;}
  51. #else
  52. #define DBG ;
  53. #define DBG_S(txt) ;
  54. #define DBG_V(var) ;
  55. #define DBG1_S(a,b) ;
  56. #define DBG2_S(a,b,c) ;
  57. #define DBG3_S(a,b,c,d) ;
  58. #define DBG4_S(a,b,c,d,e) ;
  59. #define DBG5_S(a,b,c,d,e,f) ;
  60. #define DBG6_S(a,b,c,d,e,f,h) ;
  61. #define DBG7_S(a,b,c,d,e,f,h,i) ;
  62. #define DBG8_S(a,b,c,d,e,f,h,i,j) ;
  63. #define DBG9_S(a,b,c,d,e,f,h,i,j,k) ;
  64. #define DBG_START ;
  65. #define DBG_ENDE ;
  66. #endif
  67. #define DBG_NUM if(oy_debug > 1)DBG
  68. #define DBG_NUM_S if(oy_debug > 1)DBG_S
  69. #define DBG_NUM1_S if(oy_debug > 1)DBG1_S
  70. #define DBG_NUM2_S if(oy_debug > 1)DBG2_S
  71. #define DBG_NUM3_S if(oy_debug > 1)DBG3_S
  72. #define DBG_NUM4_S if(oy_debug > 1)DBG4_S
  73. #define DBG_NUM5_S if(oy_debug > 1)DBG5_S
  74. #define DBG_NUM6_S if(oy_debug > 1)DBG6_S
  75. #define DBG_NUM7_S if(oy_debug > 1)DBG7_S
  76. #define DBG_NUM8_S if(oy_debug > 1)DBG8_S
  77. #define DBG_NUM9_S if(oy_debug > 1)DBG9_S
  78. #define DBG_NUM_V if(oy_debug > 1)DBG_V
  79. #define DBG_PROG if(oy_debug > 2)DBG
  80. #define DBG_PROG_S if(oy_debug > 2)DBG_S
  81. #define DBG_PROG1_S if(oy_debug > 2)DBG1_S
  82. #define DBG_PROG2_S if(oy_debug > 2)DBG2_S
  83. #define DBG_PROG3_S if(oy_debug > 2)DBG3_S
  84. #define DBG_PROG4_S if(oy_debug > 2)DBG4_S
  85. #define DBG_PROG5_S if(oy_debug > 2)DBG5_S
  86. #define DBG_PROG6_S if(oy_debug > 2)DBG6_S
  87. #define DBG_PROG_V if(oy_debug > 2)DBG_V
  88. #define DBG_PROG_START if(oy_debug > 2)DBG_START
  89. #define DBG_PROG_ENDE if(oy_debug > 2)DBG_ENDE
  90. #define DBG_MEM if(oy_debug > 3)DBG
  91. #define DBG_MEM_S if(oy_debug > 3)DBG_S
  92. #define DBG_MEM1_S if(oy_debug > 3)DBG1_S
  93. #define DBG_MEM2_S if(oy_debug > 3)DBG2_S
  94. #define DBG_MEM3_S if(oy_debug > 3)DBG3_S
  95. #define DBG_MEM4_S if(oy_debug > 3)DBG4_S
  96. #define DBG_MEM5_S if(oy_debug > 3)DBG5_S
  97. #define DBG_MEM6_S if(oy_debug > 3)DBG6_S
  98. #define DBG_MEM_V if(oy_debug > 3)DBG_V
  99. #define DBG_MEM_START if(oy_debug > 3)DBG_START
  100. #define DBG_MEM_ENDE if(oy_debug > 3)DBG_ENDE
  101. #endif /* defined OY_CONFIG_H */
  102. #define WARNcc(ptr) oyMessageFunc_p( oyMSG_WARN,ptr,OY_DBG_FORMAT_, OY_DBG_ARGS_ );
  103. #define WARNcc_S(ptr,txt) oyMessageFunc_p( oyMSG_WARN,ptr,OY_DBG_FORMAT_ "%s", OY_DBG_ARGS_,txt);
  104. #define WARNcc1_S(ptr,format,arg) oyMessageFunc_p( oyMSG_WARN,ptr,OY_DBG_FORMAT_ format, OY_DBG_ARGS_,arg);
  105. #define WARNcc2_S(ptr,format,arg,arg2) oyMessageFunc_p( oyMSG_WARN,ptr,OY_DBG_FORMAT_ format, OY_DBG_ARGS_,arg,arg2);
  106. #define WARNcc3_S(ptr,format,arg,arg2,arg3) oyMessageFunc_p( oyMSG_WARN,ptr,OY_DBG_FORMAT_ format, OY_DBG_ARGS_,arg,arg2,arg3);
  107. #define WARNcc4_S(ptr,format,arg,arg2,arg3,arg4) oyMessageFunc_p( oyMSG_WARN,ptr,OY_DBG_FORMAT_ format, OY_DBG_ARGS_,arg,arg2,arg3,arg4);
  108. #define WARNcc5_S(ptr,format,arg,arg2,arg3,arg4,arg5) oyMessageFunc_p( oyMSG_WARN,ptr,OY_DBG_FORMAT_ format, OY_DBG_ARGS_,arg,arg2,arg3,arg4,arg5);
  109. #define WARNc oyMessageFunc_p( oyMSG_WARN,0,OY_DBG_FORMAT_, OY_DBG_ARGS_ );
  110. #define WARNc_S(txt) oyMessageFunc_p( oyMSG_WARN,0,OY_DBG_FORMAT_ "%s", OY_DBG_ARGS_,txt);
  111. #define WARNc1_S(format,arg) oyMessageFunc_p( oyMSG_WARN,0,OY_DBG_FORMAT_ format, OY_DBG_ARGS_,arg);
  112. #define WARNc2_S(format,arg,arg2) oyMessageFunc_p( oyMSG_WARN,0,OY_DBG_FORMAT_ format, OY_DBG_ARGS_,arg,arg2);
  113. #define WARNc3_S(format,arg,arg2,arg3) oyMessageFunc_p( oyMSG_WARN,0,OY_DBG_FORMAT_ format, OY_DBG_ARGS_,arg,arg2,arg3);
  114. #define WARNc4_S(format,arg,arg2,arg3,arg4) oyMessageFunc_p( oyMSG_WARN,0,OY_DBG_FORMAT_ format, OY_DBG_ARGS_,arg,arg2,arg3,arg4);
  115. #define WARNc5_S(format,arg,arg2,arg3,arg4,arg5) oyMessageFunc_p( oyMSG_WARN,0,OY_DBG_FORMAT_ format, OY_DBG_ARGS_,arg,arg2,arg3,arg4,arg5);
  116. #define WARNc6_S(format,arg,arg2,arg3,arg4,arg5,arg6) oyMessageFunc_p( oyMSG_WARN,0,OY_DBG_FORMAT_ format, OY_DBG_ARGS_,arg,arg2,arg3,arg4,arg5,arg6);
  117. #define WARNc7_S(format,arg,arg2,arg3,arg4,arg5,arg6,arg7) oyMessageFunc_p( oyMSG_WARN,0,OY_DBG_FORMAT_ format, OY_DBG_ARGS_,arg,arg2,arg3,arg4,arg5,arg6,arg7);
  118. #define WARNc8_S(format,arg,arg2,arg3,arg4,arg5,arg6,arg7,arg8) oyMessageFunc_p( oyMSG_WARN,0,OY_DBG_FORMAT_ format, OY_DBG_ARGS_,arg,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
  119. void oy_backtrace_();
  120. #ifdef __cplusplus
  121. }
  122. #endif /* __cplusplus */
  123. #endif /* OYRANOS_DEBUG_H */