log4cpp 1.1.6
Loading...
Searching...
No Matches
NTEventLogAppender.hh
Go to the documentation of this file.
1/*
2 * NTEventLogAppender.hh
3 *
4 * See the COPYING file for the terms of usage and distribution.
5 */
6
7#ifndef _LOG4CPP_NTEVENTLOGAPPENDER_HH
8#define _LOG4CPP_NTEVENTLOGAPPENDER_HH
9
10#ifdef WIN32 // only available on Win32
11
12// deal with ERROR #define
13// N.B. This #includes windows.h with NOGDI and WIN32_LEAN_AND_MEAN #defined.
14// If this is not what the user wants, #include windows.h before this file.
15#ifndef _WINDOWS_
16#ifndef NOGDI
17#define NOGDI // this will circumvent the ERROR #define in windows.h
18#define LOG4CPP_UNDEFINE_NOGDI
19#endif
20
21#ifndef WIN32_LEAN_AND_MEAN
22#define WIN32_LEAN_AND_MEAN
23#define LOG4CPP_UNDEFINE_WIN32_LEAN_AND_MEAN
24#endif
25
26#include <windows.h>
27
28#ifdef LOG4CPP_UNDEFINE_NOGDI
29#undef NOGDI
30#endif
31
32#ifdef LOG4CPP_UNDEFINE_WIN32_LEAN_AND_MEAN
33#undef WIN32_LEAN_AND_MEAN
34#endif
35
36#endif // done dealing with ERROR #define
37
40
41namespace log4cpp {
42
53 public:
59 NTEventLogAppender(const std::string& name, const std::string& sourceName);
60 virtual ~NTEventLogAppender();
61
65 virtual bool reopen();
66
67 virtual void close();
68
73 virtual bool requiresLayout() const;
74
75 virtual void setLayout(Layout* layout);
76
77 protected:
78 WORD getCategory(Priority::Value priority);
79 WORD getType(Priority::Value priority);
80 HKEY regGetKey(TCHAR* subkey, DWORD* disposition);
81 void regSetString(HKEY hkey, TCHAR* name, TCHAR* value);
82 void regSetDword(HKEY hkey, TCHAR* name, DWORD value);
83 void addRegistryInfo(const char* source);
84
85 virtual void open();
86
91 virtual void _append(const LoggingEvent& event);
92
94 std::string _strSourceName;
95 };
96} // namespace log4cpp
97
98#else // WIN32
99#error NTEventLoggAppender is not available on on Win32 platforms
100#endif // WIN32
101
102#endif // _LOG4CPP_NTEVENTLOGAPPENDER_HH
#define LOG4CPP_EXPORT
Definition Export.hh:26
AppenderSkeleton(const std::string &name)
Constructor for AppenderSkeleton.
Definition AppenderSkeleton.cpp:15
Extend this abstract class to create your own log layout format.
Definition Layout.hh:22
void regSetDword(HKEY hkey, TCHAR *name, DWORD value)
Definition NTEventLogAppender.cpp:112
virtual void open()
Definition NTEventLogAppender.cpp:26
virtual bool requiresLayout() const
The NTEventLogAppender does its own Layout.
Definition NTEventLogAppender.cpp:43
virtual void close()
Release any resources allocated within the appender such as file handles, network connections,...
Definition NTEventLogAppender.cpp:31
WORD getType(Priority::Value priority)
Convert log4cpp Priority to an EventLog type.
Definition NTEventLogAppender.cpp:75
HKEY regGetKey(TCHAR *subkey, DWORD *disposition)
Definition NTEventLogAppender.cpp:101
virtual bool reopen()
Calls open() and close().
Definition NTEventLogAppender.cpp:37
virtual void setLayout(Layout *layout)
Set the Layout for this appender.
Definition NTEventLogAppender.cpp:47
NTEventLogAppender(const std::string &name, const std::string &sourceName)
Instantiate an NTEventLogAppender with given name and source.
Definition NTEventLogAppender.cpp:17
void regSetString(HKEY hkey, TCHAR *name, TCHAR *value)
Definition NTEventLogAppender.cpp:108
virtual void _append(const LoggingEvent &event)
Sends a LoggingEvent to NT Event log.
Definition NTEventLogAppender.cpp:51
HANDLE _hEventSource
Definition NTEventLogAppender.hh:93
void addRegistryInfo(const char *source)
Definition NTEventLogAppender.cpp:119
WORD getCategory(Priority::Value priority)
Convert log4cpp Priority to an EventLog category.
Definition NTEventLogAppender.cpp:65
std::string _strSourceName
Definition NTEventLogAppender.hh:94
int Value
The type of Priority Values.
Definition Priority.hh:85
The top level namespace for all 'Log for C++' types and classes.
Definition AbortAppender.hh:16
The internal representation of logging events.
Definition LoggingEvent.hh:32