void Application::ThreadMessages::removeThreadMessages() { std::unique_lock<std::mutex> msgLock(msg_mutex); std::thread::id curId = std::this_thread::get_id(); auto iter = m_threadMsgMap.find(curId); if (iter != m_threadMsgMap.end()) { m_threadMsgMap.erase(iter); } }
void Application::ThreadMessages::removeThreadMessages() { ScopedLock msgLock(msg_mutex); cthreadId_t curId = getThisThreadId() ; threadMsgMap_t::iterator iter = m_threadMsgMap.find(curId) ; if (iter != m_threadMsgMap.end()) { m_threadMsgMap.erase(iter) ; } }
void LOW_helper_msglog::va_printToLog( const logType_t inLogType, const char *inFormat, va_list inParamList) { FILE *extraStream = 0, *stdStream = 0; char dummy, *buffer, *indentStr, *tmpPtr; int headLen, length; msgLock lock = msgLock(); switch ( inLogType ) { case msg_log: stdStream = useStdMsgStream ? stdOutStream : NULL; extraStream = useExtraMsgStream ? extraOutStream : NULL; break; case warn_log: stdStream = useStdWarnStream ? stdWarnStream : NULL; extraStream = useExtraWarnStream ? extraWarnStream : NULL; break; case err_log: stdStream = useStdErrStream ? stdErrStream : NULL; extraStream = useExtraErrStream ? extraErrStream : NULL; break; case debug_log: stdStream = useStdDebugStream ? stdDebugStream : NULL; extraStream = useExtraDebugStream ? extraDebugStream : NULL; break; } headLen = fprintLogHeader( extraStream, stdStream); // build string for indention indentStr = new char[headLen+1]; memset( indentStr, ' ', headLen); indentStr[headLen] = '\0'; if ( inLogType==err_log ) fprintfMulti( extraStream, stdStream, "ERROR -- "); if ( inLogType==debug_log ) fprintfMulti( extraStream, stdStream, "DEBUG -- "); // detect length and reserve buffer length = vsnprintf( &dummy, 0, inFormat, inParamList); // detect length buffer = new char[length+1]; // get buffer (remember ther \0!) vsprintf( buffer, inFormat, inParamList); // print into buffer tmpPtr = strtok( buffer, "\n"); fprintfMulti( extraStream, stdStream, "%s\n", tmpPtr); // first line without indent while( (tmpPtr=strtok( NULL, "\n")) != NULL ) { // subsequent lines with indent fprintfMulti( extraStream, stdStream, "%s%s\n", indentStr, tmpPtr); } delete[] buffer; delete[] indentStr; }
Application::Messages* Application::ThreadMessages::operator ->() { std::unique_lock<std::mutex> msgLock(msg_mutex); std::thread::id curId = std::this_thread::get_id(); auto iter = m_threadMsgMap.find(curId); if (iter != m_threadMsgMap.end()) { return iter->second.get(); } pMessages_t pMsgs(new Messages()); m_threadMsgMap.insert({curId, pMsgs}); return pMsgs.get(); }
Application::Messages* Application::ThreadMessages::operator ->() { ScopedLock msgLock(msg_mutex); cthreadId_t curId = getThisThreadId() ; threadMsgMap_t::iterator iter = m_threadMsgMap.find(curId) ; if (iter != m_threadMsgMap.end()) { return iter->second.get(); } pMessages_t pMsgs(new Messages()) ; m_threadMsgMap.insert(std::pair< cthreadId_t, pMessages_t >(curId, pMsgs)) ; return pMsgs.get() ; }
void LOW_helper_msglog::setDebugLevelEnabled( const debugLevel_t inLevel, const bool isEnabled) { msgLock lock = msgLock(); debugLevels[inLevel] = isEnabled; }