00001
00002
00003
00004
00005
00006
00007 #ifndef _LOG4SHIB_NTEVENTLOGAPPENDER_HH
00008 #define _LOG4SHIB_NTEVENTLOGAPPENDER_HH
00009
00010 #ifdef WIN32 // only available on Win32
00011
00012
00013
00014
00015 #ifndef _WINDOWS_
00016 # ifndef NOGDI
00017 # define NOGDI // this will circumvent the ERROR #define in windows.h
00018 # define LOG4SHIB_UNDEFINE_NOGDI
00019 # endif
00020
00021 # ifndef WIN32_LEAN_AND_MEAN
00022 # define WIN32_LEAN_AND_MEAN
00023 # define LOG4SHIB_UNDEFINE_WIN32_LEAN_AND_MEAN
00024 # endif
00025
00026 # include <windows.h>
00027
00028 # ifdef LOG4SHIB_UNDEFINE_NOGDI
00029 # undef NOGDI
00030 # endif
00031
00032 # ifdef LOG4SHIB_UNDEFINE_WIN32_LEAN_AND_MEAN
00033 # undef WIN32_LEAN_AND_MEAN
00034 # endif
00035
00036 #endif // done dealing with ERROR #define
00037
00038 #include <log4shib/Portability.hh>
00039 #include <log4shib/LayoutAppender.hh>
00040
00041 namespace log4shib {
00042
00052 class LOG4SHIB_EXPORT NTEventLogAppender : public LayoutAppender {
00053 public:
00054
00060 NTEventLogAppender(const std::string& name, const std::string& sourceName);
00061 virtual ~NTEventLogAppender();
00062
00066 virtual bool reopen();
00067
00068 virtual void close();
00069
00070 protected:
00071
00072 WORD getCategory(Priority::Value priority);
00073 WORD getType(Priority::Value priority);
00074 HKEY regGetKey(TCHAR *subkey, DWORD *disposition);
00075 void regSetString(HKEY hkey, const TCHAR *name, const TCHAR *value);
00076 void regSetDword(HKEY hkey, const TCHAR *name, DWORD value);
00077 void addRegistryInfo(const char *source);
00078
00079 virtual void open();
00080
00085 virtual void _append(const LoggingEvent& event);
00086
00087 HANDLE _hEventSource;
00088 std::string _strSourceName;
00089 };
00090 }
00091
00092 #else // WIN32
00093 #error NTEventLoggAppender is not available on on Win32 platforms
00094 #endif // WIN32
00095
00096 #endif // _LOG4SHIB_NTEVENTLOGAPPENDER_HH
00097