Initial
This commit is contained in:
63
service/EventLog.hpp
Normal file
63
service/EventLog.hpp
Normal file
@@ -0,0 +1,63 @@
|
||||
#ifndef _SERVICE_EVENTLOG_HPP_
|
||||
#define _SERVICE_EVENTLOG_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
|
||||
class EventLog
|
||||
{
|
||||
public:
|
||||
enum EventType{Error=EVENTLOG_ERROR_TYPE,Warning=EVENTLOG_WARNING_TYPE,Information=EVENTLOG_INFORMATION_TYPE};
|
||||
EventLog(void);
|
||||
virtual ~EventLog();
|
||||
bool open(const String &strSourceName=String(),const String &strServerName=String());
|
||||
void close(void);
|
||||
bool reportEvent(const String &strMessage,EventType eventType=Error,DWORD eventID=0,WORD category=0,PSID userSID=0);
|
||||
bool isOkay(void)const;
|
||||
private:
|
||||
enum {MaxNameLength=256};
|
||||
EventLog &operator=(const EventLog &eventLog);
|
||||
EventLog(const EventLog &eventLog);
|
||||
|
||||
HANDLE mhEventLog;
|
||||
String mServerName;
|
||||
String mSourceName;
|
||||
};
|
||||
|
||||
inline
|
||||
EventLog::EventLog(void)
|
||||
: mhEventLog(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
EventLog::EventLog(const EventLog &/*eventLog*/)
|
||||
{ // private implementation
|
||||
}
|
||||
|
||||
inline
|
||||
EventLog::~EventLog()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
inline
|
||||
EventLog &EventLog::operator=(const EventLog &/*eventLog*/)
|
||||
{ // private implementation
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
void EventLog::close(void)
|
||||
{
|
||||
if(!mhEventLog)return;
|
||||
::DeregisterEventSource(mhEventLog);
|
||||
mhEventLog=0;
|
||||
}
|
||||
|
||||
inline
|
||||
bool EventLog::isOkay(void)const
|
||||
{
|
||||
return mhEventLog?true:false;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user