log4cplus
2.0.0
|
00001 // -*- C++ -*- 00002 // Module: Log4CPLUS 00003 // File: nteventlogappender.h 00004 // Created: 4/2003 00005 // Author: Michael CATANZARITI 00006 // 00007 // Copyright 2003-2015 Michael CATANZARITI 00008 // 00009 // Licensed under the Apache License, Version 2.0 (the "License"); 00010 // you may not use this file except in compliance with the License. 00011 // You may obtain a copy of the License at 00012 // 00013 // http://www.apache.org/licenses/LICENSE-2.0 00014 // 00015 // Unless required by applicable law or agreed to in writing, software 00016 // distributed under the License is distributed on an "AS IS" BASIS, 00017 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00018 // See the License for the specific language governing permissions and 00019 // limitations under the License. 00020 00023 #ifndef LOG4CPLUS_NT_EVENT_LOG_APPENDER_HEADER_ 00024 #define LOG4CPLUS_NT_EVENT_LOG_APPENDER_HEADER_ 00025 00026 #include <log4cplus/config.hxx> 00027 00028 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 00029 #pragma once 00030 #endif 00031 00032 #if defined (LOG4CPLUS_HAVE_NT_EVENT_LOG) 00033 00034 #include <log4cplus/appender.h> 00035 #include <log4cplus/config/windowsh-inc.h> 00036 00037 00038 namespace log4cplus { 00039 00043 class LOG4CPLUS_EXPORT NTEventLogAppender : public Appender { 00044 public: 00045 // ctors 00046 NTEventLogAppender(const log4cplus::tstring& server, 00047 const log4cplus::tstring& log, 00048 const log4cplus::tstring& source); 00049 NTEventLogAppender(const log4cplus::helpers::Properties & properties); 00050 00051 // dtor 00052 virtual ~NTEventLogAppender(); 00053 00054 // public Methods 00055 virtual void close(); 00056 00057 protected: 00058 virtual void append(const spi::InternalLoggingEvent& event); 00059 virtual WORD getEventType(const spi::InternalLoggingEvent& event); 00060 virtual WORD getEventCategory(const spi::InternalLoggingEvent& event); 00061 void init(); 00062 00063 /* 00064 * Add this source with appropriate configuration keys to the registry. 00065 */ 00066 void addRegistryInfo(); 00067 00068 // Data 00069 log4cplus::tstring server; 00070 log4cplus::tstring log; 00071 log4cplus::tstring source; 00072 HANDLE hEventLog; 00073 SID* pCurrentUserSID; 00074 00075 private: 00076 // Disallow copying of instances of this class 00077 NTEventLogAppender(const NTEventLogAppender&); 00078 NTEventLogAppender& operator=(const NTEventLogAppender&); 00079 }; 00080 00081 } // end namespace log4cplus 00082 00083 #endif // LOG4CPLUS_HAVE_NT_EVENT_LOG 00084 #endif //LOG4CPLUS_NT_EVENT_LOG_APPENDER_HEADER_