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.

55 lines
1.8 KiB

  1. //=======================================================================
  2. //
  3. // Copyright (c) 1998-1999 Microsoft Corporation. All Rights Reserved.
  4. //
  5. // File: log.h
  6. //
  7. // Owner: Yan Leshinsly
  8. //
  9. // Description:
  10. //
  11. // Logging support
  12. //
  13. //=======================================================================
  14. #pragma once
  15. #ifndef LOGGING_LEVEL
  16. #define LOGGING_LEVEL 0
  17. #endif
  18. const char cszLoggingFile[] = "%WinDir%\\wsdu.log";
  19. class CLogger
  20. {
  21. public:
  22. CLogger(const char* szBlockName = 0, int nLoggingLevel = 0, const char* szFileName = 0, int nLine = 0);
  23. ~CLogger();
  24. void __cdecl out(const char *szFormat, ...);
  25. void __cdecl error(const char *szFormat, ...);
  26. static void __cdecl out1(const char *szFormat, ...);
  27. static void __cdecl close(void);
  28. private:
  29. void v_out( const char* szFormat, va_list va);
  30. bool m_fOut;
  31. char m_szBlockName[64];
  32. DWORD m_dwStartTick;
  33. static FILE* c_pfile;
  34. static int c_cnIndent;
  35. static int c_cnLevels;
  36. };
  37. #define THIS_FILE __FILE__
  38. #define LOG_block(name) CLogger logger(name, LOGGING_LEVEL, THIS_FILE, __LINE__)
  39. #define LOG_out logger.out
  40. #define LOG_out1 CLogger::out1
  41. #define LOG_error logger.error
  42. #define LOG_close CLogger::close
  43. #define report_error_if_false(f) if (f) {/*OK*/} else { LOG_error("%s LastError = %d", #f, GetLastError()); }
  44. #define return_error_if_false(f) if (f) {/*OK*/} else { DWORD dwErr = GetLastError(); LOG_error("%s LastError = %d", #f, dwErr); return dwErr;}
  45. #define return_if_error(f) { DWORD dwErr = f; if (dwErr) { LOG_error("%s LastError = %d", #f, dwErr); return dwErr;} }
  46. #define return_if_false(f) if (f) {/*OK*/} else { LOG_error("%s LastError = %d", #f, GetLastError()); return FALSE;}