104 lines
2.2 KiB
C++
104 lines
2.2 KiB
C++
//----------------------------------------------------------------------------
|
|
//
|
|
// Copyright (C) Intel Corporation, 2007 - 2008.
|
|
//
|
|
// Class: MPSEventLogger.h
|
|
//
|
|
// Contents: EventLogger for MPS.
|
|
//
|
|
// Notes:
|
|
//----------------------------------------------------------------------------
|
|
|
|
#ifndef _MPS_EVENT_LOGGER_H
|
|
#define _MPS_EVENT_LOGGER_H
|
|
|
|
#include <ace/Synch.h>
|
|
|
|
#include "WindowsEventLog.h"
|
|
#include "MPSMessageFile.h"
|
|
|
|
#define EVENT_LOG_SOURCE_NAME "MPS"
|
|
#define EVENT_LOG_LOG_NAME "Application"
|
|
#define EVENT_LOG_CATEGORY_COUNT 7
|
|
|
|
class MPSEventLogger
|
|
{
|
|
friend class MPSEventLoggerWrapper;
|
|
private:
|
|
MPSEventLogger();
|
|
BaseEventLog *m_logger;
|
|
ACE_Mutex mutex;
|
|
|
|
public:
|
|
|
|
virtual ~MPSEventLogger();
|
|
|
|
// Log information event by id and category
|
|
void LogInfoEvent(unsigned short CategoryID, unsigned long EventID);
|
|
|
|
// Log error event by id and category
|
|
void LogErrorEvent(unsigned short CategoryID, unsigned long EventID);
|
|
|
|
// Record Events for debugging.
|
|
void DebugLog(const char *message);
|
|
|
|
// Record warning events
|
|
void WarningLog(const char * message);
|
|
|
|
// Record error events
|
|
void ErrorLog(const char * message);
|
|
|
|
// Reset all flags
|
|
void ResetFlags();
|
|
};
|
|
|
|
#ifdef _SERVICE
|
|
#define runAsService(X) X;
|
|
//do { \
|
|
// \
|
|
//} while(0)
|
|
#else
|
|
#define runAsService(X)
|
|
#endif
|
|
|
|
class MPSEventLoggerWrapper
|
|
{
|
|
private:
|
|
MPSEventLogger m_logger;
|
|
|
|
public:
|
|
MPSEventLoggerWrapper() : m_logger() {}
|
|
~MPSEventLoggerWrapper() {}
|
|
|
|
// Log information event by id and category
|
|
void LogInfoEvent(unsigned short CategoryID, unsigned long EventID) {
|
|
runAsService(m_logger.LogInfoEvent(CategoryID, EventID));
|
|
}
|
|
|
|
// Log error event by id and category
|
|
void LogErrorEvent(unsigned short CategoryID, unsigned long EventID) {
|
|
runAsService(m_logger.LogErrorEvent(CategoryID, EventID));
|
|
}
|
|
|
|
// Record Events for debugging.
|
|
void DebugLog(const char *message) {
|
|
runAsService(m_logger.DebugLog(message));
|
|
}
|
|
|
|
// Record warning events
|
|
void WarningLog(const char * message) {
|
|
runAsService(m_logger.WarningLog(message));
|
|
}
|
|
|
|
// Record error events
|
|
void ErrorLog(const char * message) {
|
|
runAsService(m_logger.ErrorLog(message));
|
|
}
|
|
|
|
// Reset all flags
|
|
void ResetFlags() {
|
|
runAsService(m_logger.ResetFlags());
|
|
}
|
|
};
|
|
|
|
#endif // _MPS_EVENT_LOGGER_H
|