Loading...
Searching...
No Matches
NTEventLogAppender.hh
Go to the documentation of this file.
/*
* NTEventLogAppender.hh
*
* See the COPYING file for the terms of usage and distribution.
*/
#ifndef _LOG4SHIB_NTEVENTLOGAPPENDER_HH
#define _LOG4SHIB_NTEVENTLOGAPPENDER_HH
#ifdef WIN32 // only available on Win32
// deal with ERROR #define
// N.B. This #includes windows.h with NOGDI and WIN32_LEAN_AND_MEAN #defined.
// If this is not what the user wants, #include windows.h before this file.
#ifndef _WINDOWS_
# ifndef NOGDI
# define NOGDI // this will circumvent the ERROR #define in windows.h
# define LOG4SHIB_UNDEFINE_NOGDI
# endif
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# define LOG4SHIB_UNDEFINE_WIN32_LEAN_AND_MEAN
# endif
# include <windows.h>
# ifdef LOG4SHIB_UNDEFINE_NOGDI
# undef NOGDI
# endif
# ifdef LOG4SHIB_UNDEFINE_WIN32_LEAN_AND_MEAN
# undef WIN32_LEAN_AND_MEAN
# endif
#endif // done dealing with ERROR #define
#include <log4shib/Portability.hh>
#include <log4shib/LayoutAppender.hh>
namespace log4shib {
class LOG4SHIB_EXPORT NTEventLogAppender : public LayoutAppender {
public:
NTEventLogAppender(const std::string& name, const std::string& sourceName);
virtual ~NTEventLogAppender();
virtual bool reopen();
virtual void close();
protected:
WORD getCategory(Priority::Value priority);
WORD getType(Priority::Value priority);
HKEY regGetKey(TCHAR *subkey, DWORD *disposition);
void regSetString(HKEY hkey, const TCHAR *name, const TCHAR *value);
void regSetDword(HKEY hkey, const TCHAR *name, DWORD value);
void addRegistryInfo(const char *source);
virtual void open();
virtual void _append(const LoggingEvent& event);
HANDLE _hEventSource;
std::string _strSourceName;
};
}
#else // WIN32
#error NTEventLoggAppender is not available on on Win32 platforms
#endif // WIN32
#endif // _LOG4SHIB_NTEVENTLOGAPPENDER_HH
LOG4SHIB_EXPORT
#define LOG4SHIB_EXPORT
Definition Export.hh:11
LayoutAppender.hh
Portability.hh
log4shib::LayoutAppender::LayoutAppender
LayoutAppender(const std::string &name)
Definition LayoutAppender.cpp:15
log4shib::NTEventLogAppender::reopen
virtual bool reopen()
Calls open() and close().
Definition NTEventLogAppender.cpp:39
log4shib::NTEventLogAppender::_strSourceName
std::string _strSourceName
Definition NTEventLogAppender.hh:88
log4shib::NTEventLogAppender::_append
virtual void _append(const LoggingEvent &event)
Sends a LoggingEvent to NT Event log.
Definition NTEventLogAppender.cpp:45
log4shib::NTEventLogAppender::regGetKey
HKEY regGetKey(TCHAR *subkey, DWORD *disposition)
Definition NTEventLogAppender.cpp:97
log4shib::NTEventLogAppender::regSetString
void regSetString(HKEY hkey, const TCHAR *name, const TCHAR *value)
Definition NTEventLogAppender.cpp:105
log4shib::NTEventLogAppender::getCategory
WORD getCategory(Priority::Value priority)
Convert log4shib Priority to an EventLog category.
Definition NTEventLogAppender.cpp:61
log4shib::NTEventLogAppender::open
virtual void open()
Definition NTEventLogAppender.cpp:24
log4shib::NTEventLogAppender::_hEventSource
HANDLE _hEventSource
Definition NTEventLogAppender.hh:87
log4shib::NTEventLogAppender::NTEventLogAppender
NTEventLogAppender(const std::string &name, const std::string &sourceName)
Instantiate an NTEventLogAppender with given name and source.
Definition NTEventLogAppender.cpp:11
log4shib::NTEventLogAppender::regSetDword
void regSetDword(HKEY hkey, const TCHAR *name, DWORD value)
Definition NTEventLogAppender.cpp:109
log4shib::NTEventLogAppender::addRegistryInfo
void addRegistryInfo(const char *source)
Definition NTEventLogAppender.cpp:116
log4shib::NTEventLogAppender::close
virtual void close()
Release any resources allocated within the appender such as file handles, network connections,...
Definition NTEventLogAppender.cpp:32
log4shib::NTEventLogAppender::getType
WORD getType(Priority::Value priority)
Convert log4shib Priority to an EventLog type.
Definition NTEventLogAppender.cpp:71
log4shib::Priority::Value
int Value
The type of Priority Values.
Definition Priority.hh:84
log4shib
The top level namespace for all 'Log for C++' types and classes.
Definition AbortAppender.hh:16
log4shib::LoggingEvent
The internal representation of logging events.
Definition LoggingEvent.hh:32