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.

58 lines
1.6 KiB

  1. // DbgLogr.h : This file contains the
  2. // Created: Dec '97
  3. // Author : a-rakeba
  4. // History:
  5. // Copyright (C) 1997 Microsoft Corporation
  6. // All rights reserved.
  7. // Microsoft Confidential
  8. #if !defined ( _DBGLOGR_H_ )
  9. #define _DBGLOGR_H_
  10. #include "cmnhdr.h"
  11. #include <windows.h>
  12. #include <fstream.h>
  13. #include "DbgLvl.h"
  14. namespace _Utils {
  15. class CDebugLogger {
  16. public:
  17. static bool Init( DWORD dwDebugLvl = CDebugLevel::TRACE_DEBUGGING,
  18. LPCSTR lpszLogFileName = NULL );
  19. static void ShutDown();
  20. static void OutMessage( DWORD dwDebugLvl, LPSTR lpszFmt, ... );
  21. static void OutMessage( DWORD dwDebugLvl, LPTSTR lpszFmt, ... );
  22. static void OutMessage( DWORD dwDdebugLvl, DWORD dwLineNum,
  23. LPCSTR lpszFileName );
  24. static void OutMessage( LPCSTR lpszLineDesc, LPCSTR lpszFileName,
  25. DWORD dwLineNum,
  26. DWORD dwErrNum );
  27. private:
  28. enum { BUFF_SIZE = 1024 };
  29. CDebugLogger();
  30. ~CDebugLogger();
  31. static void Synchronize( void );
  32. static void PrintTime( void );
  33. static void LogToFile( LPCSTR lpszFileName );
  34. static HANDLE s_hMutex;
  35. static LPSTR s_lpszLogFileName;
  36. static ostream* s_pOutput;
  37. };
  38. }
  39. #endif // _DBGLOGR_H_
  40. // Notes:
  41. // CDebugLogger::Init() must be called before any use of this class.
  42. // CDebugLogger::ShutDown() be called when done using the class.
  43. // The private functions have not been made thread-safe, since their
  44. // purpose in life is to be called by the thread-safe public functions.