This commit is contained in:
2024-08-07 09:16:27 -04:00
parent fdfadd5c7e
commit 5f971cf684
5200 changed files with 731717 additions and 0 deletions

63
service/EventLog.hpp Normal file
View 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