Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.5 KiB

  1. // scuDbgTracer.h -- Debug trace helpers
  2. // (c) Copyright Schlumberger Technology Corp., unpublished work, created
  3. // 1999. This computer program includes Confidential, Proprietary
  4. // Information and is a Trade Secret of Schlumberger Technology Corp. All
  5. // use, disclosure, and/or reproduction is prohibited unless authorized
  6. // in writing. All Rights Reserved.
  7. #if !defined(SLBSCU_DBGTRACE_H)
  8. #define SLBSCU_DBGTRACE_H
  9. #if defined(_DEBUG)
  10. #include <stdio.h>
  11. #include <windows.h>
  12. #include "scuExc.h"
  13. namespace scu
  14. {
  15. inline void
  16. TraceRoutine(char const *szRoutineName,
  17. char const *szAction)
  18. {
  19. FILE *pf = fopen("C:\\slbTrace.log", "a");
  20. pf = fopen("C:\\slbTrace.log", "a");
  21. if (pf)
  22. {
  23. fprintf(pf,
  24. "Routine: %s Action: %s\n",
  25. szRoutineName, szAction);
  26. fclose(pf);
  27. }
  28. }
  29. inline void
  30. TraceCatch(char const *szRoutineName,
  31. Exception const &rExc)
  32. {
  33. FILE *pf = fopen("C:\\slbTrace.log", "a");
  34. pf = fopen("C:\\slbTrace.log", "a");
  35. if (pf)
  36. {
  37. fprintf(pf,
  38. "Routine: %s Action: Catching Type: scu::Exception Facility: %u Cause: %08u (0x%08x) Description %s\n",
  39. szRoutineName, rExc.Facility(), rExc.Error(), rExc.Error(), rExc.Description());
  40. fclose(pf);
  41. }
  42. }
  43. inline void
  44. Trace(char const *szRoutineName,
  45. char const *szAction,
  46. char const *szType,
  47. DWORD dwValue)
  48. {
  49. FILE *pf = fopen("C:\\slbTrace.log", "a");
  50. pf = fopen("C:\\slbTrace.log", "a");
  51. if (pf)
  52. {
  53. fprintf(pf,
  54. "Routine: %s Action: %s Type: %s Value: 0x%08x\n",
  55. szRoutineName, szAction, szType, dwValue);
  56. fclose(pf);
  57. }
  58. }
  59. }
  60. #define SCUTRACE(RoutineName, Action, Type, dwValue) scu::Trace(RoutineName, Action, Type, (dwValue))
  61. #define SCUTRACE_RTN(RoutineName, Action) scu::TraceRoutine(RoutineName, Action)
  62. #define SCUTRACE_CATCH(RoutineName, rExc) scu::TraceCatch(RoutineName, rExc)
  63. #define SCUTRACE_THROW(RoutineName, Type, dwValue) scu::Trace(RoutineName, "Throwing", Type, dwValue)
  64. #else
  65. #define SCUTRACE(RoutineName, Action, Type, dwValue)
  66. #define SCUTRACE_RTN(RoutineName, Action)
  67. #define SCUTRACE_CATCH(RoutineName, rExc)
  68. #define SCUTRACE_THROW(RoutineName, Type, dwValue)
  69. #endif // !defined(_DEBUG)
  70. #endif // !defined(SLBSCU_DBGTRACE_H)