Index: src/libchcore/Tests/TOverlappedDataBufferQueueTests.cpp =================================================================== diff -u -rd265da146d8ea0b4318dd63c0993ba3a88a620c3 -r4a4360ee83d1051b3bfa3c42f93ca581b81d1744 --- src/libchcore/Tests/TOverlappedDataBufferQueueTests.cpp (.../TOverlappedDataBufferQueueTests.cpp) (revision d265da146d8ea0b4318dd63c0993ba3a88a620c3) +++ src/libchcore/Tests/TOverlappedDataBufferQueueTests.cpp (.../TOverlappedDataBufferQueueTests.cpp) (revision 4a4360ee83d1051b3bfa3c42f93ca581b81d1744) @@ -22,8 +22,10 @@ TEST(TOverlappedDataBufferQueueTests, DefaultConstructor_SanityTest) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + TOverlappedDataBufferQueue queue(spLogData); + EXPECT_EQ(nullptr, queue.GetEmptyBuffer()); EXPECT_EQ(nullptr, queue.GetFullBuffer()); EXPECT_EQ(nullptr, queue.GetFinishedBuffer()); @@ -45,8 +47,10 @@ TEST(TOverlappedDataBufferQueueTests, AllocatingConstructor_SanityTest) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); + EXPECT_NE(nullptr, queue.GetEmptyBuffer()); EXPECT_EQ(nullptr, queue.GetFullBuffer()); EXPECT_EQ(nullptr, queue.GetFinishedBuffer()); @@ -65,7 +69,9 @@ TEST(TOverlappedDataBufferQueueTests, AllocatingConstructor_CheckBufferSizes) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); TOverlappedDataBuffer* pBuffers[3] = { queue.GetEmptyBuffer(), queue.GetEmptyBuffer(), queue.GetEmptyBuffer() }; EXPECT_EQ(3, queue.GetTotalBufferCount()); @@ -79,23 +85,29 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// TEST(TOverlappedDataBufferQueueTests, ReinitializeBuffer_FailsWithBuffersInUse) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); + queue.GetEmptyBuffer(); EXPECT_THROW(queue.ReinitializeBuffers(3, 65536), TCoreException); } TEST(TOverlappedDataBufferQueueTests, ReinitializeBuffer_ZeroLengthBuffers) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); + EXPECT_THROW(queue.ReinitializeBuffers(3, 0), TCoreException); } TEST(TOverlappedDataBufferQueueTests, ReinitializeBuffer_SameSizeSameCount) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); queue.ReinitializeBuffers(3, 32768); TOverlappedDataBuffer* pBuffers[3] = { queue.GetEmptyBuffer(), queue.GetEmptyBuffer(), queue.GetEmptyBuffer() }; @@ -110,7 +122,9 @@ TEST(TOverlappedDataBufferQueueTests, ReinitializeBuffer_IncreaseSize) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); queue.ReinitializeBuffers(3, 65536); TOverlappedDataBuffer* pBuffers[3] = { queue.GetEmptyBuffer(), queue.GetEmptyBuffer(), queue.GetEmptyBuffer() }; @@ -125,7 +139,9 @@ TEST(TOverlappedDataBufferQueueTests, ReinitializeBuffer_DecreaseSize) { - TOverlappedDataBufferQueue queue(3, 65536); + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData, 3, 65536); queue.ReinitializeBuffers(3, 32768); TOverlappedDataBuffer* pBuffers[3] = { queue.GetEmptyBuffer(), queue.GetEmptyBuffer(), queue.GetEmptyBuffer() }; @@ -140,7 +156,9 @@ TEST(TOverlappedDataBufferQueueTests, ReinitializeBuffer_IncreaseCount) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); queue.ReinitializeBuffers(5, 32768); EXPECT_EQ(5, queue.GetTotalBufferCount()); @@ -157,7 +175,9 @@ TEST(TOverlappedDataBufferQueueTests, ReinitializeBuffer_DecreaseCount) { - TOverlappedDataBufferQueue queue(5, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData, 5, 32768); queue.ReinitializeBuffers(3, 32768); EXPECT_EQ(3, queue.GetTotalBufferCount()); @@ -173,8 +193,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// TEST(TOverlappedDataBufferQueueTests, GetEmptyBuffer) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); + EXPECT_SIGNALED(queue.GetEventReadPossibleHandle()); EXPECT_NE(nullptr, queue.GetEmptyBuffer()); @@ -191,8 +213,10 @@ TEST(TOverlappedDataBufferQueueTests, AddEmptyBuffer) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); + TOverlappedDataBuffer* pBuffers[3] = { queue.GetEmptyBuffer(), queue.GetEmptyBuffer(), queue.GetEmptyBuffer() }; EXPECT_TIMEOUT(queue.GetEventReadPossibleHandle()); @@ -209,15 +233,19 @@ TEST(TOverlappedDataBufferQueueTests, AddEmptyBuffer_Null) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); + EXPECT_THROW(queue.AddEmptyBuffer(nullptr), TCoreException); } /////////////////////////////////////////////////////////////////////////////////////////////////// TEST(TOverlappedDataBufferQueueTests, AddFullBuffer_GetFullBuffer) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); TOverlappedDataBuffer* pBuffer = queue.GetEmptyBuffer(); queue.AddFullBuffer(pBuffer); @@ -229,7 +257,9 @@ TEST(TOverlappedDataBufferQueueTests, GetFullBuffer_WrongOrder) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); TOverlappedDataBuffer* pBuffers[3] = { queue.GetEmptyBuffer(), queue.GetEmptyBuffer(), queue.GetEmptyBuffer() }; queue.AddFullBuffer(pBuffers[1]); @@ -244,7 +274,9 @@ TEST(TOverlappedDataBufferQueueTests, AddFullBuffer_HandlingSrcEof) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); TOverlappedDataBuffer* pBuffers[3] = { queue.GetEmptyBuffer(), queue.GetEmptyBuffer(), queue.GetEmptyBuffer() }; pBuffers[1]->SetLastPart(true); @@ -258,7 +290,9 @@ TEST(TOverlappedDataBufferQueueTests, AddFullBuffer_HandlingDstEof) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); TOverlappedDataBuffer* pBuffers[3] = { queue.GetEmptyBuffer(), queue.GetEmptyBuffer(), queue.GetEmptyBuffer() }; pBuffers[2]->SetLastPart(true); @@ -280,14 +314,18 @@ TEST(TOverlappedDataBufferQueueTests, AddFullBuffer_Null) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); + EXPECT_THROW(queue.AddFullBuffer(nullptr), TCoreException); } TEST(TOverlappedDataBufferQueueTests, AddFullBuffer_SameBufferTwice) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); TOverlappedDataBuffer* pBuffer = queue.GetEmptyBuffer(); pBuffer->InitForRead(0, 1280); @@ -300,7 +338,9 @@ TEST(TOverlappedDataBufferQueueTests, GetFullBuffer_AddFullBuffer_OutOfOrder) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); TOverlappedDataBuffer* pBuffers[3] = { queue.GetEmptyBuffer(), queue.GetEmptyBuffer(), queue.GetEmptyBuffer() }; pBuffers[0]->InitForRead(0, 1000); @@ -331,7 +371,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// TEST(TOverlappedDataBufferQueueTests, AddFinishedBuffer_OutOfOrder_Signals) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); TOverlappedDataBuffer* pBuffers[3] = { queue.GetEmptyBuffer(), queue.GetEmptyBuffer(), queue.GetEmptyBuffer() }; pBuffers[0]->InitForRead(0, 1000); @@ -357,7 +399,9 @@ TEST(TOverlappedDataBufferQueueTests, GetFinishedBuffer_Signals) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); TOverlappedDataBuffer* pBuffers[3] = { queue.GetEmptyBuffer(), queue.GetEmptyBuffer(), queue.GetEmptyBuffer() }; pBuffers[0]->InitForRead(0, 1000); @@ -395,7 +439,9 @@ TEST(TOverlappedDataBufferQueueTests, GetFinishedBuffer_WrongOrder) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); TOverlappedDataBuffer* pBuffers[3] = { queue.GetEmptyBuffer(), queue.GetEmptyBuffer(), queue.GetEmptyBuffer() }; pBuffers[0]->InitForRead(0, 1000); @@ -423,14 +469,18 @@ TEST(TOverlappedDataBufferQueueTests, AddFinishedBuffer_Null) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); + EXPECT_THROW(queue.AddFinishedBuffer(nullptr), TCoreException); } TEST(TOverlappedDataBufferQueueTests, AddFinishedBuffer_SameBufferTwice) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); TOverlappedDataBuffer* pBuffer = queue.GetEmptyBuffer(); queue.AddFinishedBuffer(pBuffer); EXPECT_THROW(queue.AddFinishedBuffer(pBuffer), TCoreException); @@ -439,7 +489,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// TEST(TOverlappedDataBufferQueueTests, DataSourceChanged_CleanupBuffers) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); TOverlappedDataBuffer* pBuffers[3] = { queue.GetEmptyBuffer(), queue.GetEmptyBuffer(), queue.GetEmptyBuffer() }; pBuffers[0]->SetLastPart(true); @@ -456,8 +508,10 @@ TEST(TOverlappedDataBufferQueueTests, DataSourceChanged_InvalidBufferCount) { - TOverlappedDataBufferQueue queue(3, 32768); + logger::TLogFileDataPtr spLogData(std::make_shared()); + TOverlappedDataBufferQueue queue(spLogData, 3, 32768); + queue.GetEmptyBuffer(); // this tests if the buffers are properly cleaned up - if they're not, DataSourceChanged() throws an exception Index: src/libchcore/Tests/TOverlappedDataBufferTests.cpp =================================================================== diff -u -r4160fe7ef4661c482d974476fa02eaadf1877d5b -r4a4360ee83d1051b3bfa3c42f93ca581b81d1744 --- src/libchcore/Tests/TOverlappedDataBufferTests.cpp (.../TOverlappedDataBufferTests.cpp) (revision 4160fe7ef4661c482d974476fa02eaadf1877d5b) +++ src/libchcore/Tests/TOverlappedDataBufferTests.cpp (.../TOverlappedDataBufferTests.cpp) (revision 4a4360ee83d1051b3bfa3c42f93ca581b81d1744) @@ -14,7 +14,9 @@ TEST(TOverlappedDataBufferTests, Constructor_SanityTest) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(32768, &queue); EXPECT_EQ(0, buffer.GetBufferOrder()); @@ -31,7 +33,9 @@ TEST(TOverlappedDataBufferTests, ReinitializeBuffer_ReduceSize) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(32768, &queue); buffer.ReinitializeBuffer(16384); @@ -42,7 +46,9 @@ TEST(TOverlappedDataBufferTests, ReinitializeBuffer_IncreaseSize) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(16384, &queue); buffer.ReinitializeBuffer(32768); @@ -53,7 +59,9 @@ TEST(TOverlappedDataBufferTests, SetRequestedDataSize_GetRequestedDataSize) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(16384, &queue); buffer.SetRequestedDataSize(123); @@ -63,7 +71,9 @@ TEST(TOverlappedDataBufferTests, SetRealDataSize_GetRealDataSize) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(16384, &queue); buffer.SetRealDataSize(123); @@ -73,7 +83,9 @@ TEST(TOverlappedDataBufferTests, SetLastPart_IsLastPart) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(16384, &queue); buffer.SetLastPart(true); @@ -83,7 +95,9 @@ TEST(TOverlappedDataBufferTests, SetBufferOrder_GetBufferOrder) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(16384, &queue); buffer.SetBufferOrder(123); @@ -93,7 +107,9 @@ TEST(TOverlappedDataBufferTests, SetErrorCode_GetErrorCode) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(16384, &queue); buffer.SetErrorCode(123); @@ -103,7 +119,9 @@ TEST(TOverlappedDataBufferTests, SetStatusCode_GetStatusCode) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(16384, &queue); buffer.SetStatusCode(123); @@ -113,7 +131,9 @@ TEST(TOverlappedDataBufferTests, SetBytesTransferred_GetBytesTransferred) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(16384, &queue); buffer.SetBytesTransferred(123); @@ -123,7 +143,9 @@ TEST(TOverlappedDataBufferTests, GetFilePosition_SetFilePosition) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(16384, &queue); buffer.SetFilePosition(123); @@ -134,7 +156,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// TEST(TOverlappedDataBufferTests, InitForRead) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(16384, &queue); buffer.SetRequestedDataSize(123); @@ -158,7 +182,9 @@ TEST(TOverlappedDataBufferTests, InitForWrite) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(16384, &queue); buffer.SetRequestedDataSize(123); @@ -178,7 +204,9 @@ TEST(TOverlappedDataBufferTests, Reset) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(16384, &queue); buffer.SetRequestedDataSize(123); @@ -203,7 +231,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// TEST(TOverlappedDataBufferTests, RequeueAsEmpty) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(16384, &queue); buffer.RequeueAsEmpty(); @@ -213,7 +243,9 @@ TEST(TOverlappedDataBufferTests, RequeueAsFull) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(16384, &queue); buffer.RequeueAsFull(); @@ -223,7 +255,9 @@ TEST(TOverlappedDataBufferTests, RequeueAsFinished) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(16384, &queue); buffer.RequeueAsFinished(); @@ -233,14 +267,16 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// TEST(TOverlappedDataBufferTests, OverlappedReadCompleted_Success) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(16384, &queue); buffer.InitForRead(0, 1024); buffer.SetStatusCode(0); buffer.SetBytesTransferred(234); - OverlappedReadCompleted(ERROR_SUCCESS, 234, &buffer); + OverlappedReadCompleted(ERROR_SUCCESS, 234, &buffer); EXPECT_TRUE(buffer.IsLastPart()); EXPECT_EQ(ERROR_SUCCESS, buffer.GetErrorCode()); @@ -251,14 +287,16 @@ TEST(TOverlappedDataBufferTests, OverlappedReadCompleted_Failure) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(16384, &queue); buffer.InitForRead(0, 1024); buffer.SetStatusCode(0); buffer.SetBytesTransferred(0); - OverlappedReadCompleted(ERROR_ACCESS_DENIED, 0, &buffer); + OverlappedReadCompleted(ERROR_ACCESS_DENIED, 0, &buffer); EXPECT_FALSE(buffer.IsLastPart()); EXPECT_EQ(ERROR_ACCESS_DENIED, buffer.GetErrorCode()); @@ -269,7 +307,9 @@ TEST(TOverlappedDataBufferTests, OverlappedWriteCompleted_Success) { - TOverlappedDataBufferQueue queue; + logger::TLogFileDataPtr spLogData(std::make_shared()); + + TOverlappedDataBufferQueue queue(spLogData); TOverlappedDataBuffer buffer(16384, &queue); buffer.InitForRead(0, 1024); @@ -278,7 +318,7 @@ buffer.SetLastPart(true); buffer.SetRealDataSize(234); - OverlappedWriteCompleted(ERROR_SUCCESS, 234, &buffer); + OverlappedWriteCompleted(ERROR_SUCCESS, 234, &buffer); EXPECT_EQ(ERROR_SUCCESS, buffer.GetErrorCode()); EXPECT_EQ(queue.GetFinishedBuffer(), &buffer); Index: src/liblogger/TLogFileData.cpp =================================================================== diff -u -r8f634460db3f225ca24f2e447b3730d4f0614166 -r4a4360ee83d1051b3bfa3c42f93ca581b81d1744 --- src/liblogger/TLogFileData.cpp (.../TLogFileData.cpp) (revision 8f634460db3f225ca24f2e447b3730d4f0614166) +++ src/liblogger/TLogFileData.cpp (.../TLogFileData.cpp) (revision 4a4360ee83d1051b3bfa3c42f93ca581b81d1744) @@ -21,13 +21,22 @@ namespace logger { + TLogFileData::TLogFileData() : + m_spHasEntriesEvent(CreateEvent(nullptr, TRUE, FALSE, nullptr), CloseHandle), + m_spLoggerConfig(std::make_shared()), + m_spLogFile() + { + } + TLogFileData::TLogFileData(PCTSTR pszLogPath, const TMultiLoggerConfigPtr& spLoggerConfig, const TLoggerRotationInfoPtr& spRotationInfo) : m_spHasEntriesEvent(CreateEvent(nullptr, TRUE, FALSE, nullptr), CloseHandle), m_spLoggerConfig(spLoggerConfig), - m_logFile(pszLogPath, spRotationInfo) + m_spLogFile(std::make_unique(pszLogPath, spRotationInfo)) { if(m_spHasEntriesEvent.get() == INVALID_HANDLE_VALUE) throw std::runtime_error("Cannot create file data event"); + if(!spLoggerConfig) + throw std::runtime_error("spLoggerConfig"); } TMultiLoggerConfigPtr TLogFileData::GetMultiLoggerConfig() const @@ -49,11 +58,13 @@ void TLogFileData::StoreLogEntries() { - m_logFile.Write(m_listEntries); + if(m_spLogFile) + m_spLogFile->Write(m_listEntries); } void TLogFileData::CloseUnusedFile() { - m_logFile.CloseIfUnused(); + if(m_spLogFile) + m_spLogFile->CloseIfUnused(); } } Index: src/liblogger/TLogFileData.h =================================================================== diff -u -r545098ae76e9ce23598d37d2bee4020d6cb59f3c -r4a4360ee83d1051b3bfa3c42f93ca581b81d1744 --- src/liblogger/TLogFileData.h (.../TLogFileData.h) (revision 545098ae76e9ce23598d37d2bee4020d6cb59f3c) +++ src/liblogger/TLogFileData.h (.../TLogFileData.h) (revision 4a4360ee83d1051b3bfa3c42f93ca581b81d1744) @@ -31,6 +31,7 @@ class LIBLOGGER_API TLogFileData { public: + TLogFileData(); TLogFileData(PCTSTR pszLogPath, const TMultiLoggerConfigPtr& spLoggerConfig, const TLoggerRotationInfoPtr& spRotationInfo); TMultiLoggerConfigPtr GetMultiLoggerConfig() const; @@ -52,7 +53,7 @@ TMultiLoggerConfigPtr m_spLoggerConfig; - internal::TLogFile m_logFile; + std::unique_ptr m_spLogFile; #pragma warning(pop) friend class TLogRecord;