Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cNTEventLog.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cNTEventLog_H
7 #define _INC_cNTEventLog_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "../GrayLibBase.h"
13 
14 #if defined(_WIN32) && ! defined(UNDER_CE) // Linux should be completely oblivious to this file
15 #include "GrayCore/include/cOSHandle.h" // HANDLE_NULL
18 
19 namespace GrayLib
20 {
21  class GRAYLIB_LINK cNTEventLog
22  {
26 
27  private:
28  HANDLE m_hEventSource;
29  public:
30  cNTEventLog()
31  : m_hEventSource(HANDLE_NULL)
32  {
33  }
34  ~cNTEventLog()
35  {
36  Stop();
37  }
38 
39  HRESULT InstallEventLog(const FILECHAR_t* pszName, const FILECHAR_t* pszPathEventMessageFile);
40  bool isInstalled() const
41  {
42  return(m_hEventSource != HANDLE_NULL);
43  }
44  bool Start(const FILECHAR_t* pszName);
45  void Stop();
46 
47  bool ReportEventX(WORD wType, WORD wCategory, DWORD dwEventID); // no args
48  bool _cdecl ReportEventf(WORD wType, WORD wCategory, DWORD dwEventID, ...); // args = nullptr term array of string(s).
49  };
50 
51  class GRAYLIB_LINK cNTEventAppender : public cLogAppender, public cRefBase, public cNTEventLog
52  {
56 
57  public:
58  cNTEventAppender()
59  {}
60 
61  virtual HRESULT WriteString(const LOGCHAR_t* pszMsg);
62  static HRESULT GRAYCALL AddAppenderCheck(cLogNexus* pLogger = nullptr);
63 
64  IUNKNOWN_DISAMBIG(cRefBase);
65  };
66 
67 };
68 #endif // _WIN32
69 #endif // _INC_CNTEVENTLOG_H
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
#define IUNKNOWN_DISAMBIG(TYPE)
Definition: IUnknown.h:92
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define HANDLE_NULL
Invalid OS handle for _WIN32. Not invalid OS handle for linux.
Definition: cOSHandle.h:21
Definition: cMesh.h:22
char FILECHAR_t
a UTF8 char in a file name. like TCHAR
Definition: FileName.h:22
char LOGCHAR_t
always just use UTF8 for logs, don't bother with UNICODE.
Definition: cLogLevel.h:17