//---------------------------------------------------------------------------- // // Copyright (C) Intel Corporation, 2007 - 2008. // // Class: MPSEventLogger.cpp // // Contents: EventLogger for MPS. // // Notes: //---------------------------------------------------------------------------- #include "MPSEventLogger.h" #include // Constructor MPSEventLogger::MPSEventLogger() { ResetFlags(); m_logger = new WindowsEventLog(EVENT_LOG_LOG_NAME,EVENT_LOG_SOURCE_NAME,EVENT_LOG_CATEGORY_COUNT); } MPSEventLogger::~MPSEventLogger() { delete m_logger; } // Log information event by id and category void MPSEventLogger::LogInfoEvent(unsigned short CategoryID, unsigned long EventID) { mutex.acquire(); if (m_logger != NULL) { m_logger->LogEvent(CategoryID , EventID, EVENTLOG_INFORMATION_TYPE); } mutex.release(); } // Log Error event by id and category void MPSEventLogger::LogErrorEvent(unsigned short CategoryID, unsigned long EventID) { mutex.acquire(); if (m_logger != NULL) { m_logger->LogEvent(CategoryID, EventID, EVENTLOG_ERROR_TYPE); } mutex.release(); } // Record Events for debugging. void MPSEventLogger::DebugLog(const char *message) { mutex.acquire(); ACE_TCHAR szBuf[1024]; ACE_OS::sprintf(szBuf, "%s\n", message); const ACE_TCHAR *lpStrings[] = {szBuf}; unsigned int NumOfStrings = 1; if (m_logger != NULL) { m_logger->LogEvent(MPS_GENERAL, TEXT_MESSAGE, EVENTLOG_INFORMATION_TYPE, lpStrings,NumOfStrings, NULL, 0); } #ifndef NO_STDOUT_DEBUG_LOG printf("%s", szBuf); #endif mutex.release(); } // Record warning events void MPSEventLogger::WarningLog(const char *message) { mutex.acquire(); ACE_TCHAR szBuf[1024]; ACE_OS::sprintf(szBuf, "%s\n", message); const ACE_TCHAR *lpStrings[] = {szBuf}; unsigned int NumOfStrings = 1; if (m_logger != NULL) { m_logger->LogEvent(MPS_GENERAL, MPS_WARNING_MESSAGE, EVENTLOG_WARNING_TYPE, lpStrings,NumOfStrings, NULL, 0); } #ifndef NO_STDOUT_DEBUG_LOG printf("%s", szBuf); #endif mutex.release(); } // Record error events void MPSEventLogger::ErrorLog(const char *message) { mutex.acquire(); ACE_TCHAR szBuf[1024]; ACE_OS::sprintf(szBuf, " [MPS] %s\n", message); const ACE_TCHAR *lpStrings[] = {szBuf}; unsigned int NumOfStrings = 1; if (m_logger != NULL) { m_logger->LogEvent(MPS_GENERAL, MPS_ERROR_MESSAGE, EVENTLOG_ERROR_TYPE, lpStrings,NumOfStrings, NULL, 0); } #ifndef NO_STDOUT_DEBUG_LOG printf("%s", szBuf); #endif mutex.release(); } // Reset all flags void MPSEventLogger::ResetFlags() { mutex.acquire(); // Reset flags mutex.release(); }