~GlobalCleanup() { globalMutex.lock(false); fconfig_deleteinstance(); deadYet=true; globalMutex.unlock(false); }
void LogMgr::log(const std::string& tag, const std::string& message, const char* funcName, const char* sourceFile, unsigned int lineNum) { m_TagCriticalSection.lock(); Tags::iterator findIt = m_Tags.find(tag); if (findIt != m_Tags.end()) { m_TagCriticalSection.unlock(); std::string buffer; getOutputBuffer(buffer, tag, message, funcName, sourceFile, lineNum); outputFinalBufferToLogs(buffer, tag, findIt->second); } else { m_TagCriticalSection.unlock(); } }
void safeExit(int retcode) { bool shutdown; globalMutex.lock(false); shutdown=deadYet; if(!deadYet) { deadYet=true; cleanup(); fconfig_deleteinstance(); } globalMutex.unlock(false); if(!shutdown) exit(retcode); else pthread_exit(0); }
void LogMgr::setDisplayFLags(const std::string& tag, unsigned char flags) { m_TagCriticalSection.lock(); if (flags != 0) { Tags::iterator findIt = m_Tags.find(tag); if (findIt == m_Tags.end()) m_Tags.insert(std::make_pair(tag, flags)); else findIt->second = flags; } else { m_Tags.erase(tag); } m_TagCriticalSection.unlock(); }
LogMgr::ErrorDialogResult LogMgr::error(const std::string & errorMessage, bool isFatal, const char* funcName, const char* sourceFile, unsigned int lineNum) { std::string tag = ((isFatal) ? ("FATAL") : ("ERROR")); std::string buffer; getOutputBuffer(buffer, tag, errorMessage, funcName, sourceFile, lineNum); m_TagCriticalSection.lock(); Tags::iterator findIt = m_Tags.find(tag); if (findIt != m_Tags.end()) outputFinalBufferToLogs(buffer, tag, findIt->second); m_TagCriticalSection.unlock(); int result = ::MessageBoxA(NULL, buffer.c_str(), tag.c_str(), MB_ABORTRETRYIGNORE | MB_ICONERROR | MB_DEFBUTTON3); switch (result) { case IDIGNORE: return LogMgr::LOGMGR_ERROR_IGNORE; case IDABORT: __debugbreak(); return LogMgr::LOGMGR_ERROR_RETRY; case IDRETRY: return LogMgr::LOGMGR_ERROR_RETRY; default: return LogMgr::LOGMGR_ERROR_RETRY; } }
void LogMgr::addErrorMessenger(Logger::ErrorMessenger* pMessenger) { m_MessengerCriticalSection.lock(); m_ErrorMessengers.push_back(pMessenger); m_MessengerCriticalSection.unlock(); }