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.

89 lines
2.1 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // logfile.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // Declares the class LogFile.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 08/04/1998 Original version.
  16. // 03/23/1999 Added invalidateHandle.
  17. // 03/26/1999 Added setEnabled.
  18. //
  19. ///////////////////////////////////////////////////////////////////////////////
  20. #ifndef _LOGFILE_H_
  21. #define _LOGFILE_H_
  22. #if _MSC_VER >= 1000
  23. #pragma once
  24. #endif
  25. #include <guard.h>
  26. class FileHandle;
  27. ///////////////////////////////////////////////////////////////////////////////
  28. //
  29. // CLASS
  30. //
  31. // LogFile
  32. //
  33. // DESCRIPTION
  34. //
  35. // Maintains a generic logfile that is periodically rolled over either
  36. // when a specified interval has elapsed or the logfile reaches a certain
  37. // size.
  38. //
  39. ///////////////////////////////////////////////////////////////////////////////
  40. class LogFile : Guardable
  41. {
  42. public:
  43. LogFile() throw ();
  44. ~LogFile() throw ();
  45. void setDirectory(PCWSTR szDirectory) throw ();
  46. void setEnabled(BOOL newVal) throw ();
  47. void setMaxSize(DWORDLONG newVal) throw ();
  48. void setPeriod(LONG newVal) throw ();
  49. void close() throw ();
  50. BOOL write(
  51. const SYSTEMTIME* st,
  52. const BYTE* buf,
  53. DWORD buflen,
  54. BOOL allowRetry = TRUE
  55. ) throw ();
  56. protected:
  57. // Returns the next logfile name.
  58. void getFileName(const SYSTEMTIME* st, PWSTR fname) throw ();
  59. // Invalidates the given handle.
  60. void invalidateHandle(FileHandle* handle) throw ();
  61. // Releases the current file (if any) and opens a new one.
  62. BOOL openFile(const SYSTEMTIME* st) throw ();
  63. // Scans the logfile directory to determine the next sequence number.
  64. void updateSequence() throw ();
  65. WCHAR dirPath[MAX_PATH]; // Logfile directory.
  66. BOOL enabled;
  67. ULARGE_INTEGER maxSize;
  68. LONG period;
  69. DWORD seqNum; // Next file sequence number.
  70. FileHandle* file;
  71. SYSTEMTIME whenOpened;
  72. DWORD weekOpened;
  73. ULARGE_INTEGER currentSize;
  74. };
  75. #endif // _LOGFILE_H_