Apache log4cxx  Version 0.13.0
nteventlogappender.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _LOG4CXX_NT_EVENT_LOG_APPENDER_HEADER_
19 #define _LOG4CXX_NT_EVENT_LOG_APPENDER_HEADER_
20 
22 
23 #if defined(_MSC_VER)
24  #pragma warning ( push )
25  #pragma warning ( disable: 4251 )
26 #endif
27 
28 
29 namespace log4cxx
30 {
31 namespace nt
32 {
36 class LOG4CXX_EXPORT NTEventLogAppender : public AppenderSkeleton
37 {
38  public:
44 
46  NTEventLogAppender(const LogString& server, const LogString& log,
47  const LogString& source, const LayoutPtr& layout);
48 
49  virtual ~NTEventLogAppender();
50 
51  virtual void activateOptions(log4cxx::helpers::Pool& p);
52  virtual void close();
53  virtual void setOption(const LogString& option, const LogString& value);
54 
60  bool requiresLayout() const
61  {
62  return true;
63  }
64 
65  void setSource(const LogString& source)
66  {
67  this->source.assign(source);
68  }
69 
70  const LogString& getSource() const
71  {
72  return source;
73  }
74 
75  void setLog(const LogString& log)
76  {
77  this->log.assign(log);
78  }
79 
80  const LogString& getLog() const
81  {
82  return log;
83  }
84 
85  void setServer(const LogString& server)
86  {
87  this->server.assign(server);
88  }
89 
90  const LogString& getServer() const
91  {
92  return server;
93  }
94 
95 
96  protected:
97  //
98  // these typedef are proxies for the real Win32 definitions
99  // and need to be cast to the global definitions before
100  // use with a Win32 API call
101  typedef void SID;
102  typedef void* HANDLE;
103 
104  virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
105  static unsigned short getEventType(const spi::LoggingEventPtr& event);
106  static unsigned short getEventCategory(const spi::LoggingEventPtr& event);
107  /*
108  * Add this source with appropriate configuration keys to the registry.
109  */
110  void addRegistryInfo();
111 
112  // Data
116  HANDLE hEventLog;
118  static LogString getErrorString(const LogString& function);
119 
120  private:
122  NTEventLogAppender& operator=(const NTEventLogAppender&);
123 }; // class NTEventLogAppender
124 
126 
127 } // namespace nt
128 } // namespace log4cxx
129 
130 #if defined(_MSC_VER)
131  #pragma warning (pop)
132 #endif
133 #endif //_LOG4CXX_NT_EVENT_LOG_APPENDER_HEADER_
void * HANDLE
Definition: nteventlogappender.h:102
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:153
LogString server
Definition: nteventlogappender.h:113
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:147
Implementation base class for all appenders.
Definition: appenderskeleton.h:43
const LogString & getSource() const
Definition: nteventlogappender.h:70
std::shared_ptr< LoggingEvent > LoggingEventPtr
Definition: appender.h:37
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:141
void setServer(const LogString &server)
Definition: nteventlogappender.h:85
void setSource(const LogString &source)
Definition: nteventlogappender.h:65
void SID
Definition: nteventlogappender.h:101
LOG4CXX_PTR_DEF(NTEventLogAppender)
HANDLE hEventLog
Definition: nteventlogappender.h:116
const LogString & getLog() const
Definition: nteventlogappender.h:80
Appends log events to NT EventLog.
Definition: nteventlogappender.h:36
#define DECLARE_LOG4CXX_OBJECT(object)
Definition: object.h:39
LogString log
Definition: nteventlogappender.h:114
LogString source
Definition: nteventlogappender.h:115
std::shared_ptr< Layout > LayoutPtr
Definition: appender.h:47
const LogString & getServer() const
Definition: nteventlogappender.h:90
SID * pCurrentUserSID
Definition: nteventlogappender.h:117
bool requiresLayout() const
The SocketAppender does not use a layout.
Definition: nteventlogappender.h:60
void setLog(const LogString &log)
Definition: nteventlogappender.h:75
Definition: pool.h:32
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition: object.h:159
Definition: appender.h:32
std::basic_string< logchar > LogString
Definition: logstring.h:66