Source code of Windows XP (NT5)
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.

209 lines
6.6 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. errorlog.h
  5. Abstract:
  6. This module contains the manifests and macros used for error logging
  7. in the Afp server.
  8. !!! This module must be nonpageable.
  9. Author:
  10. Jameel Hyder (microsoft!jameelh)
  11. Revision History:
  12. 10 Jun 1992 Initial Version
  13. --*/
  14. #ifndef _ERRORLOG_
  15. #define _ERRORLOG_
  16. //
  17. // Debug levels used with DBGPRINT and DBGBRK
  18. //
  19. #define DBG_LEVEL_INFO 0x0000
  20. #define DBG_LEVEL_WARN 0x1000
  21. #define DBG_LEVEL_ERR 0x2000
  22. #define DBG_LEVEL_FATAL 0x3000
  23. //
  24. // Component types used with DBGPRINT
  25. //
  26. #define DBG_COMP_INIT 0x00000001
  27. #define DBG_COMP_MEMORY 0x00000002
  28. #define DBG_COMP_FILEIO 0x00000004
  29. #define DBG_COMP_SCVGR 0x00000008
  30. #define DBG_COMP_LOCKS 0x00000010
  31. #define DBG_COMP_CHGNOTIFY 0x00000020
  32. #define DBG_COMP_SDA 0x00000040
  33. #define DBG_COMP_FORKS 0x00000080
  34. #define DBG_COMP_DESKTOP 0x00000100
  35. #define DBG_COMP_VOLUME 0x00000200
  36. #define DBG_COMP_AFPINFO 0x00000400
  37. #define DBG_COMP_IDINDEX 0x00000800
  38. #define DBG_COMP_STACKIF 0x00001000
  39. #define DBG_COMP_SECURITY 0x00002000
  40. #define DBG_COMP_ADMINAPI 0x00004000
  41. #define DBG_COMP_ADMINAPI_SC 0x00008000
  42. #define DBG_COMP_ADMINAPI_STAT 0x00010000
  43. #define DBG_COMP_ADMINAPI_SRV 0x00020000
  44. #define DBG_COMP_ADMINAPI_VOL 0x00040000
  45. #define DBG_COMP_ADMINAPI_SESS 0x00080000
  46. #define DBG_COMP_ADMINAPI_CONN 0x00100000
  47. #define DBG_COMP_ADMINAPI_FORK 0x00200000
  48. #define DBG_COMP_ADMINAPI_DIR 0x00400000
  49. #define DBG_COMP_ADMINAPI_ALL 0x007FC000
  50. #define DBG_COMP_AFPAPI 0x00800000
  51. #define DBG_COMP_AFPAPI_DTP 0x01000000
  52. #define DBG_COMP_AFPAPI_FORK 0x02000000
  53. #define DBG_COMP_AFPAPI_FILE 0x04000000
  54. #define DBG_COMP_AFPAPI_DIR 0x08000000
  55. #define DBG_COMP_AFPAPI_FD 0x10000000
  56. #define DBG_COMP_AFPAPI_VOL 0x20000000
  57. #define DBG_COMP_AFPAPI_SRV 0x40000000
  58. #define DBG_COMP_AFPAPI_ALL 0x7F800000
  59. #define DBG_COMP_NOHEADER 0x80000000
  60. #define DBG_COMP_ALL 0x7FFFFFFF
  61. // Change this to level of debugging desired. This can also be changed on the
  62. // fly via the kernel debugger
  63. #if DBG
  64. GLOBAL LONG AfpDebugLevel EQU DBG_LEVEL_ERR;
  65. GLOBAL LONG AfpDebugComponent EQU DBG_COMP_ALL;
  66. GLOBAL LONG AfpDebugRefcount EQU 0;
  67. #define DBGPRINT(Component, Level, Fmt) \
  68. if ((Level >= AfpDebugLevel) && (AfpDebugComponent & Component)) \
  69. { \
  70. if (!(Component & DBG_COMP_NOHEADER)) \
  71. DbgPrint("***AFPSRV*** "); \
  72. DbgPrint Fmt; \
  73. }
  74. #define DBGBRK(Level) \
  75. if (Level >= AfpDebugLevel) \
  76. DbgBreakPoint()
  77. #define DBGREFCOUNT(Fmt) \
  78. if (AfpDebugRefcount) \
  79. { \
  80. DbgPrint("***AFPSRV*** "); \
  81. DbgPrint Fmt; \
  82. }
  83. #else
  84. #define DBGPRINT(Component, Level, Fmt)
  85. #define DBGBRK(Level)
  86. #define DBGREFCOUNT(Fmt)
  87. #endif
  88. //
  89. // The types of events that can be logged.
  90. // (cut-n-pasted from ntelfapi.h, after the "use ntsrv.h, not ntos.h" changes)
  91. //
  92. #define EVENTLOG_ERROR_TYPE 0x0001
  93. #define EVENTLOG_INFORMATION_TYPE 0x0004
  94. // This method of logging will end up calling the IoWriteErrorlogEntry. It
  95. // should be used in places where for some reason do not want to queue up
  96. // the errorlog to be logged from the usermode service. It takes ONE insertion
  97. // string max. pInsertionString is a PUNICODE_STRING. An example of where this
  98. // should be used is in the AllocNonPagedMem routines, because if we were
  99. // to call the AfpLogEvent routine from there, it would again turn around and
  100. // call the alloc mem routine. Also any routines that are called during
  101. // server initialization/deinitialization should use this logging method since
  102. // the usermode utility worker component is not guaranteed to be up accepting
  103. // error log requests!
  104. #define AFPLOG_DDERROR(ErrMsgNum, NtStatus, RawData, RawDataLen, pInsertionString) \
  105. DBGPRINT(DBG_COMP_ALL, DBG_LEVEL_WARN, ("AFP_ERRORLOG: %s (%d) Status %lx\n", \
  106. __FILE__, __LINE__, NtStatus)); \
  107. AfpWriteErrorLogEntry(ErrMsgNum, FILENUM + __LINE__, NtStatus, \
  108. RawData, RawDataLen, \
  109. pInsertionString)
  110. // This is the most basic method of logging; takes ONE insertion string max.
  111. // pInsertionString is a PUNICODE_STRING. This will cause the errorlog to
  112. // be sent up to the usermode service to be logged.
  113. #define AFPLOG_ERROR(ErrMsgNum, NtStatus, RawData, RawDataLen, pInsertionString) \
  114. DBGPRINT(DBG_COMP_ALL, DBG_LEVEL_WARN, ("AFP_ERRORLOG: %s (%d) Status %lx\n", \
  115. __FILE__, __LINE__, NtStatus)); \
  116. AfpLogEvent(EVENTLOG_ERROR_TYPE, ErrMsgNum, FILENUM + __LINE__, NtStatus, \
  117. (PBYTE)RawData, RawDataLen, 0, \
  118. (pInsertionString == NULL) ? 0 : ((PUNICODE_STRING)(pInsertionString))->Length, \
  119. (pInsertionString == NULL) ? NULL : ((PUNICODE_STRING)(pInsertionString))->Buffer);
  120. // This method of errorlogging takes a file handle and extracts the
  121. // corresponding filename to use as the *first* insertion string.
  122. #define AFPLOG_HERROR(ErrMsgNum, NtStatus, RawData, RawDataLen, Handle) \
  123. DBGPRINT(DBG_COMP_ALL, DBG_LEVEL_ERR, ("AFP_ERRORLOG: %s (%d) Status %lx\n", \
  124. __FILE__, __LINE__, NtStatus)); \
  125. AfpLogEvent(EVENTLOG_ERROR_TYPE, ErrMsgNum, FILENUM + __LINE__, NtStatus, \
  126. (PBYTE)RawData, RawDataLen, Handle, 0, NULL)
  127. // This is the most basic method of logging; takes ONE insertion string max.
  128. // pInsertionString is a PUNICODE_STRING. This will cause the eventlog to
  129. // be sent up to the usermode service to be logged.
  130. #define AFPLOG_INFO(ErrMsgNum, NtStatus, RawData, RawDataLen, pInsertionString) \
  131. DBGPRINT(DBG_COMP_ALL, DBG_LEVEL_INFO, ("AFP_EVENTLOG: %s (%d) Status %lx\n", \
  132. __FILE__, __LINE__, NtStatus)); \
  133. AfpLogEvent(EVENTLOG_INFORMATION_TYPE, ErrMsgNum, FILENUM + __LINE__, NtStatus, \
  134. (PBYTE)RawData, RawDataLen, 0, \
  135. (pInsertionString == NULL) ? 0 : ((PUNICODE_STRING)(pInsertionString))->Length, \
  136. (pInsertionString == NULL) ? NULL : ((PUNICODE_STRING)(pInsertionString))->Buffer);
  137. //
  138. // Error levels used with AfpWriteErrorLogEntry
  139. //
  140. #define ERROR_LEVEL_EXPECTED 0
  141. #define ERROR_LEVEL_UNEXPECTED 1
  142. #define ERROR_LEVEL_IMPOSSIBLE 2
  143. #define ERROR_LEVEL_FATAL 3
  144. extern
  145. VOID
  146. AfpWriteErrorLogEntry(
  147. IN ULONG EventCode,
  148. IN LONG UniqueErrorCode OPTIONAL,
  149. IN NTSTATUS NtStatusCode,
  150. IN PVOID RawDataBuf OPTIONAL,
  151. IN LONG RawDataLen,
  152. IN PUNICODE_STRING pInsertionString OPTIONAL
  153. );
  154. // This routine is implemented in secutil.c
  155. extern
  156. VOID
  157. AfpLogEvent(
  158. IN USHORT EventType,
  159. IN ULONG MsgId,
  160. IN DWORD File_Line OPTIONAL,
  161. IN NTSTATUS Status OPTIONAL,
  162. IN PBYTE RawDataBuf OPTIONAL,
  163. IN LONG RawDataLen,
  164. IN HANDLE FileHandle OPTIONAL,
  165. IN LONG String1Len,
  166. IN PWSTR String1 OPTIONAL
  167. );
  168. #endif // _ERRORLOG_