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.

70 lines
1.4 KiB

  1. #pragma once
  2. #include <crtdbg.h>
  3. #include <malloc.h>
  4. #include <stdarg.h>
  5. #include <string.h>
  6. #include <time.h>
  7. #define IN
  8. #define OUT
  9. //
  10. // CGenLog - Const
  11. //
  12. #define GENLOG_DEFAULT_WRITEBUFSIZE 256
  13. //
  14. // CGenLog - Error Codes...
  15. //
  16. #define GENLOG_SUCCESS 0
  17. #define GENLOG_ERROR_INVALIDARG -1
  18. #define GENLOG_ERROR_UNEXPECTED -2
  19. #define GENLOG_ERROR_FILEOPERATIONFAILED -3
  20. #define GENLOG_ERROR_UNINITIALIZED -4
  21. #define GENLOG_ERROR_MEMORY -5
  22. class IGenLog {
  23. virtual void Debug( const char *pDebugString, ... ) = 0;
  24. virtual void Error( const char *pErrorString, ... ) = 0;
  25. virtual void Log( const char *pLogString, ... ) = 0;
  26. };
  27. class CGenLog : public IGenLog {
  28. FILE *m_pFileHandle;
  29. char *m_pWriteBuffer;
  30. unsigned long m_lWriteBufferLen;
  31. public:
  32. CGenLog();
  33. CGenLog(const char *pszFilePath);
  34. ~CGenLog();
  35. long
  36. InitLog
  37. (
  38. IN const char *pszFilePath = NULL,
  39. IN const char *pszMode = NULL,
  40. IN const unsigned long lWriteBuffer = GENLOG_DEFAULT_WRITEBUFSIZE
  41. );
  42. void
  43. ResetGenLog();
  44. void
  45. Header(const char *pszHeaderString = NULL);
  46. void
  47. Now();
  48. public:
  49. virtual void Debug( const char *pDebugString, ... );
  50. virtual void Error( const char *pErrorString, ... );
  51. virtual void Log( const char *pLogString, ... );
  52. protected:
  53. long Write();
  54. };