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.

124 lines
3.6 KiB

  1. /********************************************************************
  2. Copyright (c) 1996-2000 Microsoft Corporation
  3. Module Name:
  4. weblog.cpp
  5. Abstract:
  6. Defines a generic class that can be used to log
  7. info from ISAPIs. This class allows its user to
  8. create application specific logfiles and
  9. automatically uses an intermediate file to log info and
  10. creates permanent log files at predefined intervals
  11. or after predefined number of records have been
  12. written to the intermediate file.
  13. Revision History:
  14. rsraghav created 03/25/96
  15. DerekM modified 04/06/99
  16. ********************************************************************/
  17. #ifndef WEBLOG_H
  18. #define WEBLOG_H
  19. /////////////////////////////////////////////////////////////////////////////
  20. // Constant definitions
  21. const DWORD c_cMaxAppNameLen = 256;
  22. const DWORD c_cMaxTimeSuffixLen = 18; // format of the suffix:YYYYMMDDHHmmss.log
  23. const DWORD c_cMaxRecLen = 2048;
  24. const DWORD c_dwMinToMS = 60000;
  25. const DWORD c_dwFTtoMS = 10000;
  26. const LPCWSTR c_szTempLogfileSuffix = L".iwl";
  27. const LPCWSTR c_szPermLogfileSuffix = L".log";
  28. /////////////////////////////////////////////////////////////////////////////
  29. // Registry keys, values, and defaults
  30. const LPCWSTR c_szRPWeblogRootKey = L"Software\\Microsoft\\WebLog";
  31. const LPCWSTR c_szRVMaxRecords = L"MaxTempRecs";
  32. const LPCWSTR c_szRVCurrentRecs = L"CurTempRecs";
  33. const LPCWSTR c_szRVLastDumpTime = L"LastDumpTime";
  34. const LPCWSTR c_szRVDumpInterval = L"DumpIntervalMin";
  35. const LPCWSTR c_szRVLogFilePath = L"LogFilePath";
  36. const LPCWSTR c_szLogFilePathDefault = L"\\";
  37. const DWORD c_dwMaxRecordsDefault = 10000;
  38. const DWORD c_dwCurrentRecDefault = 0;
  39. const DWORD c_dwDumpIntervalDefault = 60;
  40. /////////////////////////////////////////////////////////////////////////////
  41. // structs
  42. struct SAppLogInfo
  43. {
  44. WCHAR wszName[MAX_PATH];
  45. WCHAR wszLogPath[MAX_PATH];
  46. DWORD cDumpMins;
  47. DWORD cMaxTempRecs;
  48. };
  49. struct SAppLogInfoExtra
  50. {
  51. WCHAR wszName[MAX_PATH];
  52. FILETIME ftLastDump;
  53. DWORD cCurTempRecs;
  54. };
  55. //////////////////////////////////////////////////////////////////////
  56. // CWebLog definition
  57. class CWeblog
  58. {
  59. private:
  60. // member data
  61. unsigned __int64 m_liDumpIntervalAsFT;
  62. CRITICAL_SECTION m_cs;
  63. WCHAR m_szAppName[c_cMaxAppNameLen + 1];
  64. WCHAR m_szFileName[MAX_PATH + 1];
  65. WCHAR m_szFilePath[MAX_PATH + 1];
  66. DWORD m_cMaxRecords;
  67. DWORD m_dwDumpInterval;
  68. BOOL m_fInit;
  69. DWORD m_cRecords;
  70. HANDLE m_hFile;
  71. FILETIME m_ftLastDump;
  72. // internal methods
  73. void Cleanup();
  74. void Lock() { EnterCriticalSection(&m_cs); }
  75. void Unlock() { LeaveCriticalSection(&m_cs); }
  76. HRESULT InitFromRegistry();
  77. HRESULT DumpLog();
  78. BOOL IsDumpRequired();
  79. public:
  80. CWeblog(void);
  81. ~CWeblog(void);
  82. HRESULT InitLogging(LPCWSTR szAppName);
  83. HRESULT TerminateLogging(void);
  84. HRESULT LogRecord(LPCWSTR szFormat, ... );
  85. };
  86. //////////////////////////////////////////////////////////////////////
  87. // weblog configuration stuff
  88. HRESULT ReadALI(LPCWSTR wszName, SAppLogInfo *pali,
  89. SAppLogInfoExtra *palie = NULL);
  90. HRESULT WriteALI(SAppLogInfo *pali, SAppLogInfoExtra *palie = NULL);
  91. HRESULT DeleteALI(LPCWSTR wszName);
  92. #endif // WEBLOG_H_