ntdebug.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. * END COPYRIGHT BLOCK **/
  6. /******************************************************
  7. *
  8. * ntdebug.c - Sends debug output to window and stdout
  9. * on Win32 platforms.
  10. *
  11. ******************************************************/
  12. #if defined( _WIN32 )
  13. #include <windows.h>
  14. #include <time.h>
  15. #include <stdio.h>
  16. #if defined( SLAPD_LOGGING )
  17. #include "slap.h"
  18. #include "proto-slap.h"
  19. #else
  20. #include "ldap.h"
  21. #include "ldaplog.h"
  22. #endif
  23. int slapd_ldap_debug = LDAP_DEBUG_ANY;
  24. FILE *error_logfp = NULL;
  25. void LDAPDebug( int level, char *fmt, ... )
  26. {
  27. va_list arg_ptr;
  28. va_start( arg_ptr, fmt );
  29. if ( slapd_ldap_debug & level )
  30. {
  31. char szFormattedString[512];
  32. PR_vsnprintf( szFormattedString, sizeof( szFormattedString ), fmt, arg_ptr );
  33. #if defined( LDAP_DEBUG )
  34. /* Send to debug window ...*/
  35. OutputDebugString( szFormattedString );
  36. /* ... and to stderr */
  37. fprintf( stderr, szFormattedString );
  38. #endif
  39. #if defined( SLAPD_LOGGING )
  40. if ( error_logfp != NULL )
  41. slapd_log_error( error_logfp, szFormattedString );
  42. #endif
  43. }
  44. va_end( arg_ptr );
  45. }
  46. #endif