ldaplog.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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_BACKLDBM 0x80000 /*524288 */
  66. #define LDAP_DEBUG_ALL_LEVELS 0xFFFFF
  67. /* debugging stuff */
  68. /* Disable by default */
  69. #define LDAPDebug( level, fmt, arg1, arg2, arg3 )
  70. #define LDAPDebugLevelIsSet( level ) (0)
  71. #define LDAPDebug0Args( level, fmt )
  72. #define LDAPDebug1Arg( level, fmt, arg )
  73. #define LDAPDebug2Args( level, fmt, arg1, arg2 )
  74. #ifdef LDAP_DEBUG
  75. # undef LDAPDebug
  76. # undef LDAPDebug0Args
  77. # undef LDAPDebug1Arg
  78. # undef LDAPDebug2Args
  79. # undef LDAPDebugLevelIsSet
  80. /* SLAPD_LOGGING should not be on for WINSOCK (16-bit Windows) */
  81. # if defined(SLAPD_LOGGING)
  82. # ifdef _WIN32
  83. # ifndef DONT_DECLARE_SLAPD_LDAP_DEBUG /* see libglobs.c for info */
  84. extern __declspec(dllimport) int slapd_ldap_debug;
  85. # endif /* DONT_DECLARE_SLAPD_LDAP_DEBUG */
  86. # define LDAPDebug( level, fmt, arg1, arg2, arg3 ) \
  87. { \
  88. if ( *module_ldap_debug & level ) { \
  89. slapd_log_error_proc( NULL, fmt, arg1, arg2, arg3 ); \
  90. } \
  91. }
  92. # define LDAPDebug0Args( level, fmt ) \
  93. { \
  94. if ( *module_ldap_debug & level ) { \
  95. slapd_log_error_proc( NULL, fmt ); \
  96. } \
  97. }
  98. # define LDAPDebug1Arg( level, fmt, arg ) \
  99. { \
  100. if ( *module_ldap_debug & level ) { \
  101. slapd_log_error_proc( NULL, fmt, arg ); \
  102. } \
  103. }
  104. # define LDAPDebug2Args( level, fmt, arg1, arg2 ) \
  105. { \
  106. if ( *module_ldap_debug & level ) { \
  107. slapd_log_error_proc( NULL, fmt, arg1, arg2 ); \
  108. } \
  109. }
  110. # define LDAPDebugLevelIsSet( level ) (0 != (*module_ldap_debug & level))
  111. # else /* Not _WIN32 */
  112. extern int slapd_ldap_debug;
  113. # define LDAPDebug( level, fmt, arg1, arg2, arg3 ) \
  114. { \
  115. if ( slapd_ldap_debug & level ) { \
  116. slapd_log_error_proc( NULL, fmt, arg1, arg2, arg3 ); \
  117. } \
  118. }
  119. # define LDAPDebug0Args( level, fmt ) \
  120. { \
  121. if ( slapd_ldap_debug & level ) { \
  122. slapd_log_error_proc( NULL, fmt ); \
  123. } \
  124. }
  125. # define LDAPDebug1Arg( level, fmt, arg ) \
  126. { \
  127. if ( slapd_ldap_debug & level ) { \
  128. slapd_log_error_proc( NULL, fmt, arg ); \
  129. } \
  130. }
  131. # define LDAPDebug2Args( level, fmt, arg1, arg2 ) \
  132. { \
  133. if ( slapd_ldap_debug & level ) { \
  134. slapd_log_error_proc( NULL, fmt, arg1, arg2 ); \
  135. } \
  136. }
  137. # define LDAPDebugLevelIsSet( level ) (0 != (slapd_ldap_debug & level))
  138. # endif /* Win32 */
  139. # else /* no SLAPD_LOGGING */
  140. extern void ber_err_print( char * );
  141. extern int slapd_ldap_debug;
  142. # define LDAPDebug( level, fmt, arg1, arg2, arg3 ) \
  143. if ( slapd_ldap_debug & level ) { \
  144. char msg[256]; \
  145. PR_snprintf( msg, sizeof(msg), fmt, arg1, arg2, arg3 ); \
  146. ber_err_print( msg ); \
  147. }
  148. # define LDAPDebug0Args( level, fmt ) \
  149. if ( slapd_ldap_debug & level ) { \
  150. char msg[256]; \
  151. PR_snprintf( msg, sizeof(msg), fmt ); \
  152. ber_err_print( msg ); \
  153. }
  154. # define LDAPDebug1Arg( level, fmt, arg ) \
  155. if ( slapd_ldap_debug & level ) { \
  156. char msg[256]; \
  157. PR_snprintf( msg, sizeof(msg), fmt, arg ); \
  158. ber_err_print( msg ); \
  159. }
  160. # define LDAPDebug2Args( level, fmt, arg1, arg2 ) \
  161. if ( slapd_ldap_debug & level ) { \
  162. char msg[256]; \
  163. PR_snprintf( msg, sizeof(msg), fmt, arg1, arg2 ); \
  164. ber_err_print( msg ); \
  165. }
  166. # define LDAPDebugLevelIsSet( level ) (0 != (slapd_ldap_debug & level))
  167. # endif /* SLAPD_LOGGING */
  168. #endif /* LDAP_DEBUG */
  169. #ifdef __cplusplus
  170. }
  171. #endif
  172. #endif /* _LDAP_H */