Index: src/liblogger/TAsyncMultiLogger.cpp =================================================================== diff -u -N -r12b36349f6214befeace08efa9acc7e03be0d847 -r8f634460db3f225ca24f2e447b3730d4f0614166 --- src/liblogger/TAsyncMultiLogger.cpp (.../TAsyncMultiLogger.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) +++ src/liblogger/TAsyncMultiLogger.cpp (.../TAsyncMultiLogger.cpp) (revision 8f634460db3f225ca24f2e447b3730d4f0614166) @@ -20,6 +20,7 @@ #include "TAsyncMultiLogger.h" #include #include +#include namespace logger { @@ -33,6 +34,8 @@ m_spStopEvent(CreateEvent(nullptr, TRUE, FALSE, nullptr), CloseHandle), m_spGlobalRotationInfo(std::make_shared()) { + if (!m_spStopEvent) + throw std::runtime_error("Cannot create stop event"); } void TAsyncMultiLogger::FinishLogging() @@ -75,15 +78,17 @@ return m_spGlobalRotationInfo; } - void TAsyncMultiLogger::SetRotationInfo(unsigned long long ullMaxLogSize, unsigned long ulMaxRotatedCount) + void TAsyncMultiLogger::SetRotationInfo(unsigned int uiMaxLogSize, unsigned int uiMaxRotatedCount) { - m_spGlobalRotationInfo->SetRotationInfo(ullMaxLogSize, ulMaxRotatedCount); + m_spGlobalRotationInfo->SetMaxLogSize(uiMaxLogSize); + m_spGlobalRotationInfo->SetRotatedCount(uiMaxRotatedCount); } void TAsyncMultiLogger::LoggingThread() { std::vector vHandles; + bool bStopProcessing = false; do { { @@ -96,7 +101,10 @@ DWORD dwWaitResult = WaitForMultipleObjectsEx(boost::numeric_cast(vHandles.size()), &vHandles[ 0 ], FALSE, 500, FALSE); if(dwWaitResult == WAIT_OBJECT_0) - return; + { + bStopProcessing = true; + break; + } std::vector vLogs; { @@ -106,11 +114,18 @@ for (const TLogFileDataPtr& spLogData : vLogs) { - spLogData->StoreLogEntries(); - spLogData->CloseUnusedFile(); + try + { + spLogData->StoreLogEntries(); + spLogData->CloseUnusedFile(); + } + catch (const std::exception& e) + { + ATLTRACE(e.what()); + } } } - while(true); + while(!bStopProcessing); } }