00001
00002
00003
00004
00005
00006
00007 #ifndef _LOG4CPP_NTEVENTLOGAPPENDER_HH
00008 #define _LOG4CPP_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 LOG4CPP_UNDEFINE_NOGDI
00019 # endif
00020
00021 # ifndef WIN32_LEAN_AND_MEAN
00022 # define WIN32_LEAN_AND_MEAN
00023 # define LOG4CPP_UNDEFINE_WIN32_LEAN_AND_MEAN
00024 # endif
00025
00026 # include <windows.h>
00027
00028 # ifdef LOG4CPP_UNDEFINE_NOGDI
00029 # undef NOGDI
00030 # endif
00031
00032 # ifdef LOG4CPP_UNDEFINE_WIN32_LEAN_AND_MEAN
00033 # undef WIN32_LEAN_AND_MEAN
00034 # endif
00035
00036 #endif // done dealing with ERROR #define
00037
00038 #include <log4cpp/Portability.hh>
00039 #include <log4cpp/AppenderSkeleton.hh>
00040
00041 namespace log4cpp {
00042
00052 class LOG4CPP_EXPORT NTEventLogAppender : public AppenderSkeleton {
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
00074 virtual bool requiresLayout() const;
00075
00076 virtual void setLayout(Layout* layout);
00077
00078 protected:
00079
00080 WORD getCategory(Priority::Value priority);
00081 WORD getType(Priority::Value priority);
00082 HKEY regGetKey(TCHAR *subkey, DWORD *disposition);
00083 void regSetString(HKEY hkey, TCHAR *name, TCHAR *value);
00084 void regSetDword(HKEY hkey, TCHAR *name, DWORD value);
00085 void addRegistryInfo(const char *source);
00086
00087 virtual void open();
00088
00093 virtual void _append(const LoggingEvent& event);
00094
00095 HANDLE _hEventSource;
00096 std::string _strSourceName;
00097 };
00098 }
00099
00100 #else // WIN32
00101 #error NTEventLoggAppender is not available on on Win32 platforms
00102 #endif // WIN32
00103
00104 #endif // _LOG4CPP_NTEVENTLOGAPPENDER_HH
00105