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.

360 lines
6.9 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. log.h
  5. Abstract:
  6. Implements routines that simplify the writing to setupact.log
  7. and setuperr.log.
  8. Author:
  9. Jim Schmidt (jimschm) 25-Feb-1997
  10. Revision History:
  11. mikeco 23-May-1997 Ran code through train_wreck.exe
  12. Ovidiu Temereanca (ovidiut) 23-Oct-1998
  13. Added new logging capabilities
  14. */
  15. //
  16. // If either DBG or DEBUG defined, use debug mode
  17. //
  18. #ifdef DBG
  19. #ifndef DEBUG
  20. #define DEBUG
  21. #endif
  22. #endif
  23. #ifdef DEBUG
  24. #ifndef DBG
  25. #define DBG
  26. #endif
  27. #endif
  28. //
  29. // Redefine MYASSERT
  30. //
  31. #ifdef DEBUG
  32. #ifdef MYASSERT
  33. #undef MYASSERT
  34. #endif
  35. #define DBG_ASSERT "Assert"
  36. #define MYASSERT(expr) LogIfA( \
  37. !(expr), \
  38. DBG_ASSERT, \
  39. "Assert Failure\n\n%s\n\n%s line %u", \
  40. #expr, \
  41. __FILE__, \
  42. __LINE__ \
  43. );
  44. #else
  45. #ifndef MYASSERT
  46. #define MYASSERT(x)
  47. #endif
  48. #endif
  49. #define LOG_FATAL_ERROR "Fatal Error"
  50. #define LOG_ERROR "Error"
  51. #define LOG_WARNING "Warning"
  52. #define LOG_INFORMATION "Info"
  53. #define LOG_ACCOUNTS "Accounts"
  54. #define LOG_CONFIG "Configuration"
  55. BOOL
  56. LogInit (
  57. IN HWND LogPopupParentWnd
  58. );
  59. BOOL
  60. LogReInit (
  61. IN HWND *NewParent, OPTIONAL
  62. OUT HWND *OrgParent OPTIONAL
  63. );
  64. VOID
  65. LogExit (
  66. VOID
  67. );
  68. VOID
  69. _cdecl
  70. LogA (
  71. IN PCSTR Type,
  72. IN PCSTR Format,
  73. ...
  74. );
  75. VOID
  76. _cdecl
  77. LogW (
  78. IN PCSTR Type,
  79. IN PCSTR Format,
  80. ...
  81. );
  82. VOID
  83. _cdecl
  84. LogIfA (
  85. IN BOOL Condition,
  86. IN PCSTR Type,
  87. IN PCSTR Format,
  88. ...
  89. );
  90. VOID
  91. _cdecl
  92. LogIfW (
  93. IN BOOL Condition,
  94. IN PCSTR Type,
  95. IN PCSTR Format,
  96. ...
  97. );
  98. VOID
  99. LogTitleA (
  100. IN PCSTR Type,
  101. IN PCSTR Title
  102. );
  103. VOID
  104. LogTitleW (
  105. IN PCSTR Type,
  106. IN PCWSTR Title
  107. );
  108. VOID
  109. LogLineA (
  110. IN PCSTR Line
  111. );
  112. VOID
  113. LogLineW (
  114. IN PCWSTR Line
  115. );
  116. VOID
  117. LogDirectA (
  118. IN PCSTR Type,
  119. IN PCSTR Text
  120. );
  121. VOID
  122. LogDirectW (
  123. IN PCSTR Type,
  124. IN PCWSTR Text
  125. );
  126. VOID
  127. SuppressAllLogPopups (
  128. IN BOOL SuppressOn
  129. );
  130. #ifdef PROGRESS_BAR
  131. VOID
  132. _cdecl
  133. LogTime (
  134. IN PCSTR Format,
  135. ...
  136. );
  137. #endif
  138. // Define W symbols
  139. #define LOGW(x) LogW x
  140. #define LOGW_IF(x) LogIfW x
  141. #define ELSE_LOGW(x) else{LogW x;}
  142. #define ELSE_LOGW_IF(x) else{LogIfW x;}
  143. #define LOGTITLEW(type,title) LogTitleW (type,title)
  144. #define LOGLINEW(title) LogLineW (title)
  145. #define LOGDIRECTW(type,text) LogDirectW (type,text)
  146. // Define A symbols
  147. #define LOGA(x) LogA x
  148. #define LOGA_IF(x) LogIfA x
  149. #define ELSE_LOGA(x) else{LogA x;}
  150. #define ELSE_LOGA_IF(x) else{LogIfA x;}
  151. #define LOGTITLEA(type,title) LogTitleA (type,title)
  152. #define LOGLINEA(line) LogLineA (line)
  153. #define LOGDIRECTA(type,text) LogDirectA (type,text)
  154. // Define generic symbols
  155. #ifdef UNICODE
  156. #define LOG(x) LOGW(x)
  157. #define LOG_IF(x) LOGW_IF(x)
  158. #define ELSE_LOG(x) ELSE_LOGW(x)
  159. #define ELSE_LOG_IF(x) ELSE_LOGW_IF(x)
  160. #define LOGTITLE(type,title) LOGTITLEW(type,title)
  161. #define LOGLINE(title) LOGLINEW(title)
  162. #define LOGDIRECT(type,text) LOGDIRECTW(type,text)
  163. #else
  164. #define LOG(x) LOGA(x)
  165. #define LOG_IF(x) LOGA_IF(x)
  166. #define ELSE_LOG(x) ELSE_LOGA(x)
  167. #define ELSE_LOG_IF(x) ELSE_LOGA_IF(x)
  168. #define LOGTITLE(type,title) LOGTITLEA(type,title)
  169. #define LOGLINE(title) LOGLINEA(title)
  170. #define LOGDIRECT(type,text) LOGDIRECTA(type,text)
  171. #endif // UNICODE
  172. #ifdef DEBUG
  173. #define DBG_NAUSEA "Nausea"
  174. #define DBG_VERBOSE "Verbose"
  175. #define DBG_STATS "Stats"
  176. #define DBG_WARNING "Warning"
  177. #define DBG_ERROR "Error"
  178. #define DBG_WHOOPS "Whoops"
  179. #define DBG_TRACK "Track"
  180. #define DBG_TIME "Time"
  181. extern CHAR g_DebugInfPathBufA[];
  182. extern WCHAR g_DebugInfPathBufW[];
  183. #define g_DebugInfPath g_DebugInfPathBufA
  184. #define g_DebugInfPathA g_DebugInfPathBufA
  185. #define g_DebugInfPathW g_DebugInfPathBufW
  186. extern BOOL g_ResetLog; // Defined in log.c
  187. #define SET_RESETLOG() g_ResetLog = TRUE
  188. #define CLR_RESETLOG() g_ResetLog = FALSE
  189. #define RESETLOG() (g_ResetLog)
  190. extern BOOL g_DoLog; // Defined in log.c
  191. #define SET_DOLOG() g_DoLog = TRUE
  192. #define CLR_DOLOG() g_DoLog = FALSE
  193. #define DOLOG() (g_DoLog)
  194. #ifndef PROGRESS_BAR
  195. VOID
  196. _cdecl
  197. DebugLogTimeA (
  198. IN PCSTR Format,
  199. ...
  200. );
  201. VOID
  202. _cdecl
  203. DebugLogTimeW (
  204. IN PCSTR Format,
  205. ...
  206. );
  207. #endif
  208. // Define W symbols
  209. #define DEBUGMSGW(x) LogW x
  210. #define DEBUGMSGW_IF(x) LogIfW x
  211. #define ELSE_DEBUGMSGW(x) else LogW x
  212. #define ELSE_DEBUGMSGW_IF(x) else LogW x
  213. #ifdef PROGRESS_BAR
  214. #define DEBUGLOGTIMEW(x) LogTime x
  215. #else
  216. #define DEBUGLOGTIMEW(x) DebugLogTimeW x
  217. #endif
  218. // Define A symbols
  219. #define DEBUGMSGA(x) LogA x
  220. #define DEBUGMSGA_IF(x) LogIfA x
  221. #define ELSE_DEBUGMSGA(x) else LogA x
  222. #define ELSE_DEBUGMSGA_IF(x) else LogIfA x
  223. #ifdef PROGRESS_BAR
  224. #define DEBUGLOGTIMEA(x) LogTime x
  225. #else
  226. #define DEBUGLOGTIMEA(x) DebugLogTimeA x
  227. #endif
  228. // Define generic symbols
  229. #ifdef UNICODE
  230. #define DEBUGMSG(x) DEBUGMSGW(x)
  231. #define DEBUGMSG_IF(x) DEBUGMSGW_IF(x)
  232. #define ELSE_DEBUGMSG(x) ELSE_DEBUGMSGW(x)
  233. #define ELSE_DEBUGMSG_IF(x) ELSE_DEBUGMSGW_IF(x)
  234. #define DEBUGLOGTIME(x) DEBUGLOGTIMEW(x)
  235. #else
  236. #define DEBUGMSG(x) DEBUGMSGA(x)
  237. #define DEBUGMSG_IF(x) DEBUGMSGA_IF(x)
  238. #define ELSE_DEBUGMSG(x) ELSE_DEBUGMSGA(x)
  239. #define ELSE_DEBUGMSG_IF(x) ELSE_DEBUGMSGA_IF(x)
  240. #define DEBUGLOGTIME(x) DEBUGLOGTIMEA(x)
  241. #endif // UNICODE
  242. #else // !defined(DEBUG)
  243. //
  244. // No-debug constants
  245. //
  246. #define SET_RESETLOG()
  247. #define CLR_RESETLOG()
  248. #define RESETLOG()
  249. #define SET_DOLOG()
  250. #define CLR_DOLOG()
  251. #define DOLOG()
  252. #define SETTRACKCOMMENT(RetType,Msg,File,Line)
  253. #define CLRTRACKCOMMENT
  254. #define SETTRACKCOMMENT_VOID(Msg,File,Line)
  255. #define CLRTRACKCOMMENT_VOID
  256. #define DISABLETRACKCOMMENT()
  257. #define ENABLETRACKCOMMENT()
  258. #define DEBUGMSG(x)
  259. #define DEBUGMSGA(x)
  260. #define DEBUGMSGW(x)
  261. #define DEBUGMSG_IF(x)
  262. #define DEBUGMSGA_IF(x)
  263. #define DEBUGMSGW_IF(x)
  264. #define ELSE_DEBUGMSG(x)
  265. #define ELSE_DEBUGMSGA(x)
  266. #define ELSE_DEBUGMSGW(x)
  267. #define ELSE_DEBUGMSG_IF(x)
  268. #define ELSE_DEBUGMSGA_IF(x)
  269. #define ELSE_DEBUGMSGW_IF(x)
  270. #ifdef PROGRESS_BAR
  271. #define DEBUGLOGTIME(x) LogTime x
  272. #else
  273. #define DEBUGLOGTIME(x)
  274. #endif
  275. #endif // DEBUG