ldaplog.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. #ifdef HAVE_CONFIG_H
  39. # include <config.h>
  40. #endif
  41. #ifndef _LDAPLOG_H
  42. #define _LDAPLOG_H
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. #define LDAP_DEBUG_TRACE 0x00001 /* 1 */
  47. #define LDAP_DEBUG_PACKETS 0x00002 /* 2 */
  48. #define LDAP_DEBUG_ARGS 0x00004 /* 4 */
  49. #define LDAP_DEBUG_CONNS 0x00008 /* 8 */
  50. #define LDAP_DEBUG_BER 0x00010 /* 16 */
  51. #define LDAP_DEBUG_FILTER 0x00020 /* 32 */
  52. #define LDAP_DEBUG_CONFIG 0x00040 /* 64 */
  53. #define LDAP_DEBUG_ACL 0x00080 /* 128 */
  54. #define LDAP_DEBUG_STATS 0x00100 /* 256 */
  55. #define LDAP_DEBUG_STATS2 0x00200 /* 512 */
  56. #define LDAP_DEBUG_SHELL 0x00400 /* 1024 */
  57. #define LDAP_DEBUG_PARSE 0x00800 /* 2048 */
  58. #define LDAP_DEBUG_HOUSE 0x01000 /* 4096 */
  59. #define LDAP_DEBUG_REPL 0x02000 /* 8192 */
  60. #define LDAP_DEBUG_ANY 0x04000 /* 16384 */
  61. #define LDAP_DEBUG_CACHE 0x08000 /* 32768 */
  62. #define LDAP_DEBUG_PLUGIN 0x10000 /* 65536 */
  63. #define LDAP_DEBUG_TIMING 0x20000 /*131072 */
  64. #define LDAP_DEBUG_ACLSUMMARY 0x40000 /*262144 */
  65. #define LDAP_DEBUG_ALL_LEVELS 0xFFFFF
  66. /* debugging stuff */
  67. /* Disable by default */
  68. #define LDAPDebug( level, fmt, arg1, arg2, arg3 )
  69. #define LDAPDebugLevelIsSet( level ) (0)
  70. #define LDAPDebug0Args( level, fmt )
  71. #define LDAPDebug1Arg( level, fmt, arg )
  72. #define LDAPDebug2Args( level, fmt, arg1, arg2 )
  73. #ifdef LDAP_DEBUG
  74. # undef LDAPDebug
  75. # undef LDAPDebug0Args
  76. # undef LDAPDebug1Arg
  77. # undef LDAPDebug2Args
  78. # undef LDAPDebugLevelIsSet
  79. /* SLAPD_LOGGING should not be on for WINSOCK (16-bit Windows) */
  80. # if defined(SLAPD_LOGGING)
  81. # ifdef _WIN32
  82. # ifndef DONT_DECLARE_SLAPD_LDAP_DEBUG /* see libglobs.c for info */
  83. extern __declspec(dllimport) int slapd_ldap_debug;
  84. # endif /* DONT_DECLARE_SLAPD_LDAP_DEBUG */
  85. # define LDAPDebug( level, fmt, arg1, arg2, arg3 ) \
  86. { \
  87. if ( *module_ldap_debug & level ) { \
  88. slapd_log_error_proc( NULL, fmt, arg1, arg2, arg3 ); \
  89. } \
  90. }
  91. # define LDAPDebug0Args( level, fmt ) \
  92. { \
  93. if ( *module_ldap_debug & level ) { \
  94. slapd_log_error_proc( NULL, fmt ); \
  95. } \
  96. }
  97. # define LDAPDebug1Arg( level, fmt, arg ) \
  98. { \
  99. if ( *module_ldap_debug & level ) { \
  100. slapd_log_error_proc( NULL, fmt, arg ); \
  101. } \
  102. }
  103. # define LDAPDebug2Args( level, fmt, arg1, arg2 ) \
  104. { \
  105. if ( *module_ldap_debug & level ) { \
  106. slapd_log_error_proc( NULL, fmt, arg1, arg2 ); \
  107. } \
  108. }
  109. # define LDAPDebugLevelIsSet( level ) (0 != (*module_ldap_debug & level))
  110. # else /* Not _WIN32 */
  111. extern int slapd_ldap_debug;
  112. # define LDAPDebug( level, fmt, arg1, arg2, arg3 ) \
  113. { \
  114. if ( slapd_ldap_debug & level ) { \
  115. slapd_log_error_proc( NULL, fmt, arg1, arg2, arg3 ); \
  116. } \
  117. }
  118. # define LDAPDebug0Args( level, fmt ) \
  119. { \
  120. if ( slapd_ldap_debug & level ) { \
  121. slapd_log_error_proc( NULL, fmt ); \
  122. } \
  123. }
  124. # define LDAPDebug1Arg( level, fmt, arg ) \
  125. { \
  126. if ( slapd_ldap_debug & level ) { \
  127. slapd_log_error_proc( NULL, fmt, arg ); \
  128. } \
  129. }
  130. # define LDAPDebug2Args( level, fmt, arg1, arg2 ) \
  131. { \
  132. if ( slapd_ldap_debug & level ) { \
  133. slapd_log_error_proc( NULL, fmt, arg1, arg2 ); \
  134. } \
  135. }
  136. # define LDAPDebugLevelIsSet( level ) (0 != (slapd_ldap_debug & level))
  137. # endif /* Win32 */
  138. # else /* no SLAPD_LOGGING */
  139. extern void ber_err_print( char * );
  140. extern int slapd_ldap_debug;
  141. # define LDAPDebug( level, fmt, arg1, arg2, arg3 ) \
  142. if ( slapd_ldap_debug & level ) { \
  143. char msg[256]; \
  144. PR_snprintf( msg, sizeof(msg), fmt, arg1, arg2, arg3 ); \
  145. ber_err_print( msg ); \
  146. }
  147. # define LDAPDebug0Args( level, fmt ) \
  148. if ( slapd_ldap_debug & level ) { \
  149. char msg[256]; \
  150. PR_snprintf( msg, sizeof(msg), fmt ); \
  151. ber_err_print( msg ); \
  152. }
  153. # define LDAPDebug1Arg( level, fmt, arg ) \
  154. if ( slapd_ldap_debug & level ) { \
  155. char msg[256]; \
  156. PR_snprintf( msg, sizeof(msg), fmt, arg ); \
  157. ber_err_print( msg ); \
  158. }
  159. # define LDAPDebug2Args( level, fmt, arg1, arg2 ) \
  160. if ( slapd_ldap_debug & level ) { \
  161. char msg[256]; \
  162. PR_snprintf( msg, sizeof(msg), fmt, arg1, arg2 ); \
  163. ber_err_print( msg ); \
  164. }
  165. # define LDAPDebugLevelIsSet( level ) (0 != (slapd_ldap_debug & level))
  166. # endif /* SLAPD_LOGGING */
  167. #endif /* LDAP_DEBUG */
  168. #ifdef __cplusplus
  169. }
  170. #endif
  171. #endif /* _LDAP_H */