Index: src/ch/MainWnd.cpp =================================================================== diff -u -rb26ced3298e3e7e51d91f3ac70b56746786da83b -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision b26ced3298e3e7e51d91f3ac70b56746786da83b) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -43,6 +43,7 @@ #include "TTaskManagerWrapper.h" #include "CfgProperties.h" #include "resource.h" +#include "../liblogger/TAsyncMultiLogger.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -237,12 +238,16 @@ CString strError; CString strTasksDir = GetTasksDirectory(); - TSQLiteSerializerFactoryPtr spSerializerFactory(new TSQLiteSerializerFactory(PathFromString(strTasksDir))); + TSmartPath pathEngineLog = PathFromString(strTasksDir) + PathFromString(_T("engine.log")); + + logger::TLogFileDataPtr spLogFileData = logger::TAsyncMultiLogger::GetInstance()->CreateLoggerData(pathEngineLog.ToString(), GetApp().GetEngineLoggerConfig()); + + TSQLiteSerializerFactoryPtr spSerializerFactory(new TSQLiteSerializerFactory(PathFromString(strTasksDir), spLogFileData)); IFeedbackHandlerFactoryPtr spFeedbackFactory(new CFeedbackHandlerFactory); try { - m_spTasks.reset(new chcore::TTaskManager(spSerializerFactory, spFeedbackFactory, PathFromString(strTasksDir), GetApp().GetEngineLoggerConfig())); + m_spTasks.reset(new chcore::TTaskManager(spSerializerFactory, spFeedbackFactory, PathFromString(strTasksDir), GetApp().GetEngineLoggerConfig(), spLogFileData)); } catch(const std::exception& e) { @@ -253,7 +258,7 @@ { if(MsgBox(IDS_TASKMANAGER_LOAD_FAILED, MB_ICONERROR | MB_OKCANCEL) == IDOK) { - m_spTasks.reset(new chcore::TTaskManager(spSerializerFactory, spFeedbackFactory, PathFromString(strTasksDir), GetApp().GetEngineLoggerConfig(), true)); + m_spTasks.reset(new chcore::TTaskManager(spSerializerFactory, spFeedbackFactory, PathFromString(strTasksDir), GetApp().GetEngineLoggerConfig(), spLogFileData, true)); } else return false; Index: src/ch/ProgressListBox.cpp =================================================================== diff -u -rb26ced3298e3e7e51d91f3ac70b56746786da83b -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/ch/ProgressListBox.cpp (.../ProgressListBox.cpp) (revision b26ced3298e3e7e51d91f3ac70b56746786da83b) +++ src/ch/ProgressListBox.cpp (.../ProgressListBox.cpp) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -17,7 +17,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "stdafx.h" -#include "../libchcore/TTaskManager.h" #include "ProgressListBox.h" #include "MemDC.h" Index: src/ch/ch.cpp =================================================================== diff -u -rd9527df01ee91b35d9a5fdccb80ded25a9c8265f -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/ch/ch.cpp (.../ch.cpp) (revision d9527df01ee91b35d9a5fdccb80ded25a9c8265f) +++ src/ch/ch.cpp (.../ch.cpp) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -32,7 +32,6 @@ #include "../common/version.h" #include "TCommandLineParser.h" #include "../libchcore/TStringSet.h" -#include "../libchcore/SerializerTrace.h" #include "TMsgBox.h" #include "resource.h" #include "../liblogger/TLogger.h" @@ -260,6 +259,11 @@ m_spEngineLoggerConfig->SetLogLevel(L"ST-CopyMove", (logger::ESeverityLevel)GetPropValue(rCfg)); m_spEngineLoggerConfig->SetLogLevel(L"ST-Delete", (logger::ESeverityLevel)GetPropValue(rCfg)); m_spEngineLoggerConfig->SetLogLevel(L"ST-ScanDirs", (logger::ESeverityLevel)GetPropValue(rCfg)); + m_spEngineLoggerConfig->SetLogLevel(L"Serializer", (logger::ESeverityLevel)GetPropValue(rCfg)); + m_spEngineLoggerConfig->SetLogLevel(L"Serializer-RowReader", (logger::ESeverityLevel)GetPropValue(rCfg)); + m_spEngineLoggerConfig->SetLogLevel(L"Serializer-RowData", (logger::ESeverityLevel)GetPropValue(rCfg)); + m_spEngineLoggerConfig->SetLogLevel(L"Serializer-Container", (logger::ESeverityLevel)GetPropValue(rCfg)); + m_spEngineLoggerConfig->SetLogLevel(L"TaskManager", (logger::ESeverityLevel)GetPropValue(rCfg)); // initialize the global log file if it is requested by configuration file CString strLogPath = strPath + _T("\\ch.log"); Index: src/libchcore/ISerializerFactory.h =================================================================== diff -u -rd9527df01ee91b35d9a5fdccb80ded25a9c8265f -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/ISerializerFactory.h (.../ISerializerFactory.h) (revision d9527df01ee91b35d9a5fdccb80ded25a9c8265f) +++ src/libchcore/ISerializerFactory.h (.../ISerializerFactory.h) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -21,6 +21,7 @@ #include "TString.h" #include "ISerializer.h" +#include "../liblogger/TLogFileData.h" namespace chcore { @@ -30,7 +31,7 @@ virtual ~ISerializerFactory(); virtual ISerializerPtr CreateTaskManagerSerializer(bool bForceRecreate = false) = 0; - virtual ISerializerPtr CreateTaskSerializer(const TString& strNameHint = _T(""), bool bForceRecreate = false) = 0; + virtual ISerializerPtr CreateTaskSerializer(const logger::TLogFileDataPtr& spLogFileData, const TString& strNameHint = _T(""), bool bForceRecreate = false) = 0; }; typedef std::shared_ptr ISerializerFactoryPtr; Fisheye: Tag e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 refers to a dead (removed) revision in file `src/libchcore/SerializerTrace.h'. Fisheye: No comparison available. Pass `N' to diff? Index: src/libchcore/TSQLiteSerializer.cpp =================================================================== diff -u -rd9527df01ee91b35d9a5fdccb80ded25a9c8265f -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TSQLiteSerializer.cpp (.../TSQLiteSerializer.cpp) (revision d9527df01ee91b35d9a5fdccb80ded25a9c8265f) +++ src/libchcore/TSQLiteSerializer.cpp (.../TSQLiteSerializer.cpp) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -23,15 +23,15 @@ #include "ErrorCodes.h" #include "TSQLiteTransaction.h" #include "TSimpleTimer.h" -#include "SerializerTrace.h" namespace chcore { using namespace sqlite; - TSQLiteSerializer::TSQLiteSerializer(const TSmartPath& pathDB, const ISerializerSchemaPtr& spSchema) : + TSQLiteSerializer::TSQLiteSerializer(const TSmartPath& pathDB, const ISerializerSchemaPtr& spSchema, const logger::TLogFileDataPtr& spLogFileData) : m_spDatabase(new TSQLiteDatabase(pathDB)), - m_spSchema(spSchema) + m_spSchema(spSchema), + m_spLog(logger::MakeLogger(spLogFileData, L"Serializer")) { if(!m_spDatabase) throw TCoreException(eErr_InvalidArgument, L"m_spDatabase", LOCATION); @@ -57,7 +57,7 @@ if (iterMap == m_mapContainers.end()) iterMap = m_mapContainers.insert(std::make_pair( strContainerName, - std::make_shared(strContainerName, m_spDatabase, m_poolStrings))).first; + std::make_shared(strContainerName, m_spDatabase, m_poolStrings, m_spLog->GetLogFileData()))).first; return iterMap->second; } @@ -69,7 +69,7 @@ void TSQLiteSerializer::Flush() { - DBTRACE0(_T(" ## Serializer::Flush() - started\n")); + LOG_DEBUG(m_spLog) << L"Starting serializer flushing"; TSQLiteTransaction tran(m_spDatabase); @@ -85,13 +85,13 @@ tran.Commit(); unsigned long long ullFlushCommitTime = timer.Checkpoint(); ullFlushCommitTime; - DBTRACE2(_T(" ## Serializer::Flush() - container flushes: %I64u ms, transaction commit: %I64u ms\n"), ullFlushGatherTime, ullFlushCommitTime); + LOG_DEBUG(m_spLog) << L"Container flush time: " << ullFlushGatherTime << L" ms, transaction commit: " << ullFlushCommitTime << L" ms"; m_mapContainers.clear(); m_poolStrings.Clear(); unsigned long long ullFlushClearTime = timer.Checkpoint(); ullFlushClearTime; - DBTRACE1(_T(" ## Serializer::Flush() - container clearing: %I64u ms\n"), ullFlushClearTime); + LOG_DEBUG(m_spLog) << L"Container clearing: " << ullFlushClearTime << L" ms"; } void TSQLiteSerializer::SetupDBOptions() Index: src/libchcore/TSQLiteSerializer.h =================================================================== diff -u -r12ee49f6bf1f8921500ee2078e0a8c2d7b6d2a45 -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TSQLiteSerializer.h (.../TSQLiteSerializer.h) (revision 12ee49f6bf1f8921500ee2078e0a8c2d7b6d2a45) +++ src/libchcore/TSQLiteSerializer.h (.../TSQLiteSerializer.h) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -28,13 +28,15 @@ #include "TSQLiteSerializerContainer.h" #include "ISQLiteSerializerSchema.h" #include "TPlainStringPool.h" +#include "../liblogger/TLogFileData.h" +#include "../liblogger/TLogger.h" namespace chcore { class LIBCHCORE_API TSQLiteSerializer : public ISerializer { public: - TSQLiteSerializer(const TSmartPath& pathDB, const ISerializerSchemaPtr& spSchema); + TSQLiteSerializer(const TSmartPath& pathDB, const ISerializerSchemaPtr& spSchema, const logger::TLogFileDataPtr& spLogFileData); virtual ~TSQLiteSerializer(); TSmartPath GetLocation() const override; @@ -53,6 +55,7 @@ ContainerMap m_mapContainers; TPlainStringPool m_poolStrings; + logger::TLoggerPtr m_spLog; #pragma warning(pop) }; Index: src/libchcore/TSQLiteSerializerContainer.cpp =================================================================== diff -u -rd9527df01ee91b35d9a5fdccb80ded25a9c8265f -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TSQLiteSerializerContainer.cpp (.../TSQLiteSerializerContainer.cpp) (revision d9527df01ee91b35d9a5fdccb80ded25a9c8265f) +++ src/libchcore/TSQLiteSerializerContainer.cpp (.../TSQLiteSerializerContainer.cpp) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -24,19 +24,19 @@ #include "TSQLiteStatement.h" #include "TSQLiteSerializerRowReader.h" #include "TRemovedObjects.h" -#include "SerializerTrace.h" #include #include "TSerializerException.h" namespace chcore { using namespace sqlite; - TSQLiteSerializerContainer::TSQLiteSerializerContainer(const TString& strName, const sqlite::TSQLiteDatabasePtr& spDB, TPlainStringPool& poolStrings) : + TSQLiteSerializerContainer::TSQLiteSerializerContainer(const TString& strName, const sqlite::TSQLiteDatabasePtr& spDB, TPlainStringPool& poolStrings, const logger::TLogFileDataPtr& spLogFileData) : m_pPoolRows(nullptr), m_strName(strName), m_spDB(spDB), - m_poolStrings(poolStrings) + m_poolStrings(poolStrings), + m_spLog(logger::MakeLogger(spLogFileData, L"Serializer-Container")) { } @@ -58,12 +58,12 @@ if (!pMemoryBlock) throw TSerializerException(eErr_InternalProblem, _T("Cannot allocate memory"), LOCATION); - iterFnd = m_mapRows.insert(std::make_pair(oidRowID, TSQLiteSerializerRowData(oidRowID, m_tColumns, bMarkAsAdded, (unsigned long long*)pMemoryBlock, GetPool().get_requested_size(), m_poolStrings))).first; + iterFnd = m_mapRows.insert(std::make_pair(oidRowID, std::make_unique(oidRowID, m_tColumns, bMarkAsAdded, (unsigned long long*)pMemoryBlock, GetPool().get_requested_size(), m_poolStrings, m_spLog->GetLogFileData()))).first; } else if (bMarkAsAdded) - iterFnd->second.MarkAsAdded(); + iterFnd->second->MarkAsAdded(); - return (*iterFnd).second; + return *(*iterFnd).second.get(); } void TSQLiteSerializerContainer::DeleteRow(object_id_t oidRowID) @@ -106,7 +106,7 @@ ISerializerRowReaderPtr TSQLiteSerializerContainer::GetRowReader() { - TSQLiteSerializerRowReaderPtr spRowReader(new TSQLiteSerializerRowReader(m_spDB, m_tColumns, m_strName)); + TSQLiteSerializerRowReaderPtr spRowReader(new TSQLiteSerializerRowReader(m_spDB, m_tColumns, m_strName, m_spLog->GetLogFileData())); return spRowReader; } @@ -125,12 +125,12 @@ for (RowMap::iterator iterRows = m_mapRows.begin(); iterRows != m_mapRows.end(); ++iterRows) { - unsigned long long rowID = iterRows->second.GetChangeIdentification(); + unsigned long long rowID = iterRows->second->GetChangeIdentification(); iterMapGroups = mapGroups.find(rowID); if (iterMapGroups == mapGroups.end()) iterMapGroups = mapGroups.insert(std::make_pair(rowID, std::vector())).first; - iterMapGroups->second.push_back(&iterRows->second); + iterMapGroups->second.push_back(iterRows->second.get()); } TSQLiteStatement tStatement(m_spDB); @@ -145,7 +145,7 @@ TString strQuery = rGroupRows.front()->GetQuery(m_strName); if (!strQuery.IsEmpty()) { - DBTRACE2(_T("Preparing query for %lu records: %s\n"), (unsigned long)iterMapGroups->second.size(), strQuery.c_str()); + LOG_DEBUG(m_spLog) << L"Preparing query for " << (unsigned long)iterMapGroups->second.size() << L" records: " << strQuery; tStatement.Prepare(strQuery.c_str()); @@ -177,7 +177,7 @@ tStatement.ClearBindings(); tStatement.BindValue(1, idObj); - DBTRACE1_D(_T("Executing query: %s\n"), strQuery.c_str()); + LOG_DEBUG(m_spLog) << L"Executing query: " << strQuery; tStatement.Step(); } } Index: src/libchcore/TSQLiteSerializerContainer.h =================================================================== diff -u -rb26ced3298e3e7e51d91f3ac70b56746786da83b -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TSQLiteSerializerContainer.h (.../TSQLiteSerializerContainer.h) (revision b26ced3298e3e7e51d91f3ac70b56746786da83b) +++ src/libchcore/TSQLiteSerializerContainer.h (.../TSQLiteSerializerContainer.h) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -27,13 +27,14 @@ #include "TSQLiteSerializerRowData.h" #include #include +#include "../liblogger/TLogger.h" namespace chcore { class LIBCHCORE_API TSQLiteSerializerContainer : public ISerializerContainer { public: - TSQLiteSerializerContainer(const TString& strName, const sqlite::TSQLiteDatabasePtr& spDB, TPlainStringPool& poolStrings); + TSQLiteSerializerContainer(const TString& strName, const sqlite::TSQLiteDatabasePtr& spDB, TPlainStringPool& poolStrings, const logger::TLogFileDataPtr& spLogFileData); TSQLiteSerializerContainer(const TSQLiteSerializerContainer&) = delete; virtual ~TSQLiteSerializerContainer(); @@ -61,7 +62,7 @@ boost::pool<>* m_pPoolRows; - typedef boost::container::flat_map RowMap; // maps row id to row data + typedef boost::container::flat_map> RowMap; // maps row id to row data RowMap m_mapRows; boost::container::flat_set m_setDeleteItems; @@ -70,6 +71,8 @@ sqlite::TSQLiteDatabasePtr m_spDB; TPlainStringPool& m_poolStrings; + + logger::TLoggerPtr m_spLog; #pragma warning(pop) }; Index: src/libchcore/TSQLiteSerializerFactory.cpp =================================================================== diff -u -ra4635addad389b9e117679437a3e1b64a739ea96 -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TSQLiteSerializerFactory.cpp (.../TSQLiteSerializerFactory.cpp) (revision a4635addad389b9e117679437a3e1b64a739ea96) +++ src/libchcore/TSQLiteSerializerFactory.cpp (.../TSQLiteSerializerFactory.cpp) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -30,8 +30,9 @@ namespace chcore { - TSQLiteSerializerFactory::TSQLiteSerializerFactory(const TSmartPath& pathSerializeDir) : - m_pathSerializeDir(pathSerializeDir) + TSQLiteSerializerFactory::TSQLiteSerializerFactory(const TSmartPath& pathSerializeDir, logger::TLogFileDataPtr& spLogFileData) : + m_pathSerializeDir(pathSerializeDir), + m_spLog(logger::MakeLogger(spLogFileData, L"Serializer")) { } @@ -55,12 +56,13 @@ TSQLiteSerializerPtr spSerializer(std::make_shared( pathTaskManager, - std::make_shared())); + std::make_shared(), + m_spLog->GetLogFileData())); return spSerializer; } - ISerializerPtr TSQLiteSerializerFactory::CreateTaskSerializer(const TString& strNameHint, bool bForceRecreate) + ISerializerPtr TSQLiteSerializerFactory::CreateTaskSerializer(const logger::TLogFileDataPtr& spLogFileData, const TString& strNameHint, bool bForceRecreate) { TString strName(strNameHint); if (strName.IsEmpty()) @@ -90,7 +92,7 @@ } } - TSQLiteSerializerPtr spSerializer(std::make_shared(pathTask, std::make_shared())); + TSQLiteSerializerPtr spSerializer(std::make_shared(pathTask, std::make_shared(), spLogFileData)); return spSerializer; } Index: src/libchcore/TSQLiteSerializerFactory.h =================================================================== diff -u -rc085b65f1de24f25feab2bac2d5882abf04aabcf -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TSQLiteSerializerFactory.h (.../TSQLiteSerializerFactory.h) (revision c085b65f1de24f25feab2bac2d5882abf04aabcf) +++ src/libchcore/TSQLiteSerializerFactory.h (.../TSQLiteSerializerFactory.h) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -21,20 +21,25 @@ #include "TPath.h" #include "ISerializerFactory.h" +#include "../liblogger/TLogger.h" namespace chcore { class LIBCHCORE_API TSQLiteSerializerFactory : public ISerializerFactory { public: - explicit TSQLiteSerializerFactory(const TSmartPath& pathSerializeDir); + explicit TSQLiteSerializerFactory(const TSmartPath& pathSerializeDir, logger::TLogFileDataPtr& spLogFileData); virtual ~TSQLiteSerializerFactory(); ISerializerPtr CreateTaskManagerSerializer(bool bForceRecreate = false) override; - ISerializerPtr CreateTaskSerializer(const TString& strNameHint = _T(""), bool bForceRecreate = false) override; + ISerializerPtr CreateTaskSerializer(const logger::TLogFileDataPtr& spLogFileData, const TString& strNameHint = _T(""), bool bForceRecreate = false) override; private: TSmartPath m_pathSerializeDir; +#pragma warning(push) +#pragma warning(disable: 4251) + logger::TLoggerPtr m_spLog; +#pragma warning(pop) }; typedef std::shared_ptr TSQLiteSerializerFactoryPtr; Index: src/libchcore/TSQLiteSerializerRowData.cpp =================================================================== diff -u -rd9527df01ee91b35d9a5fdccb80ded25a9c8265f -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TSQLiteSerializerRowData.cpp (.../TSQLiteSerializerRowData.cpp) (revision d9527df01ee91b35d9a5fdccb80ded25a9c8265f) +++ src/libchcore/TSQLiteSerializerRowData.cpp (.../TSQLiteSerializerRowData.cpp) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -22,16 +22,16 @@ #include #include "TSerializerException.h" #include "ErrorCodes.h" -#include "SerializerTrace.h" #include "TPlainStringPool.h" namespace chcore { /////////////////////////////////////////////////////////////////////////// - TSQLiteSerializerRowData::TSQLiteSerializerRowData(object_id_t oidRowID, TSQLiteColumnsDefinition& rColumnDefinition, bool bAdded, unsigned long long* pPoolMemory, size_t stPoolMemorySizeInBytes, TPlainStringPool& poolStrings) : + TSQLiteSerializerRowData::TSQLiteSerializerRowData(object_id_t oidRowID, TSQLiteColumnsDefinition& rColumnDefinition, bool bAdded, unsigned long long* pPoolMemory, size_t stPoolMemorySizeInBytes, TPlainStringPool& poolStrings, const logger::TLogFileDataPtr& spLogFileData) : m_pPoolMemory(pPoolMemory), m_rColumns(rColumnDefinition), - m_poolStrings(poolStrings) + m_poolStrings(poolStrings), + m_spLog(logger::MakeLogger(spLogFileData, L"Serializer-RowData")) { if (!m_pPoolMemory) throw TSerializerException(eErr_InvalidArgument, _T("Null memory provided"), LOCATION); @@ -49,13 +49,6 @@ MarkAsAdded(); } - TSQLiteSerializerRowData::TSQLiteSerializerRowData(const TSQLiteSerializerRowData& rSrc) : - m_pPoolMemory(rSrc.m_pPoolMemory), - m_rColumns(rSrc.m_rColumns), - m_poolStrings(rSrc.m_poolStrings) - { - } - TSQLiteSerializerRowData::~TSQLiteSerializerRowData() { } @@ -387,6 +380,8 @@ void TSQLiteSerializerRowData::BindParams(sqlite::TSQLiteStatement &tStatement, int& iSQLiteColumnNumber, size_t stSkipColumn) { + LOG_DEBUG(m_spLog) << L"Binding parameters"; + size_t stCount = m_rColumns.GetCount(); for (size_t stColumn = 0; stColumn < stCount; ++stColumn) { @@ -400,71 +395,71 @@ case IColumnsDefinition::eType_bool: { bool bValue = GetDataForColumn(stColumn) != 0 ? true : false; - DBTRACE1_D(_T("- param(bool): %ld\n"), bValue ? 1l : 0l); + LOG_TRACE(m_spLog) << L"BindValue - column: " << stColumn << L", value(bool): " << (bValue ? 1l : 0l); tStatement.BindValue(iSQLiteColumnNumber++, bValue); break; } case IColumnsDefinition::eType_short: { short siValue = *(short*)(unsigned short*)&GetDataForColumn(stColumn); - DBTRACE1_D(_T("- param(short): %d\n"), siValue); + LOG_TRACE(m_spLog) << L"BindValue - column: " << stColumn << L", value(short): " << siValue; tStatement.BindValue(iSQLiteColumnNumber++, siValue); break; } case IColumnsDefinition::eType_ushort: { unsigned short usiValue = (unsigned short)GetDataForColumn(stColumn); - DBTRACE1_D(_T("- param(ushort): %u\n"), usiValue); + LOG_TRACE(m_spLog) << L"BindValue - column: " << stColumn << L", value(ushort): " << usiValue; tStatement.BindValue(iSQLiteColumnNumber++, usiValue); break; } case IColumnsDefinition::eType_int: { int iValue = *(int*)(unsigned int*)&GetDataForColumn(stColumn); - DBTRACE1_D(_T("- param(int): %ld\n"), iValue); + LOG_TRACE(m_spLog) << L"BindValue - column: " << stColumn << L", value(int): " << iValue; tStatement.BindValue(iSQLiteColumnNumber++, iValue); break; } case IColumnsDefinition::eType_uint: { unsigned int uiValue = (unsigned int)GetDataForColumn(stColumn); - DBTRACE1_D(_T("- param(uint): %lu\n"), uiValue); + LOG_TRACE(m_spLog) << L"BindValue - column: " << stColumn << L", value(uint): " << uiValue; tStatement.BindValue(iSQLiteColumnNumber++, uiValue); break; } case IColumnsDefinition::eType_long: { long lValue = *(long*)(unsigned long*)&GetDataForColumn(stColumn); - DBTRACE1_D(_T("- param(long): %ld\n"), lValue); + LOG_TRACE(m_spLog) << L"BindValue - column: " << stColumn << L", value(long): " << lValue; tStatement.BindValue(iSQLiteColumnNumber++, lValue); break; } case IColumnsDefinition::eType_ulong: { unsigned long ulValue = (unsigned long)GetDataForColumn(stColumn); - DBTRACE1_D(_T("- param(ulong): %lu\n"), ulValue); + LOG_TRACE(m_spLog) << L"BindValue - column: " << stColumn << L", value(ulong): " << ulValue; tStatement.BindValue(iSQLiteColumnNumber++, ulValue); break; } case IColumnsDefinition::eType_longlong: { long long llValue = *(long long*)(unsigned long long*)&GetDataForColumn(stColumn); - DBTRACE1_D(_T("- param(llong): %I64d\n"), llValue); + LOG_TRACE(m_spLog) << L"BindValue - column: " << stColumn << L", value(llong): " << llValue; tStatement.BindValue(iSQLiteColumnNumber++, llValue); break; } case IColumnsDefinition::eType_ulonglong: { unsigned long long ullValue = GetDataForColumn(stColumn); - DBTRACE1_D(_T("- param(ullong): %I64u\n"), ullValue); + LOG_TRACE(m_spLog) << L"BindValue - column: " << stColumn << L", value(ullong): " << ullValue; tStatement.BindValue(iSQLiteColumnNumber++, ullValue); break; } @@ -473,23 +468,23 @@ { // cppcheck-suppress invalidPointerCast double dValue = *(double*)(unsigned long long*)&GetDataForColumn(stColumn); - DBTRACE1_D(_T("- param(double): %f\n"), dValue); + LOG_TRACE(m_spLog) << L"BindValue - column: " << stColumn << L", value(double): " << dValue; tStatement.BindValue(iSQLiteColumnNumber++, dValue); break; } case IColumnsDefinition::eType_string: { const wchar_t* pszValue = (const wchar_t*)(unsigned long long*)GetDataForColumn(stColumn); - DBTRACE1_D(_T("- param(string): %s\n"), pszValue ? pszValue : _T("")); + LOG_TRACE(m_spLog) << L"BindValue - column: " << stColumn << L", value(string): " << (pszValue ? pszValue : _T("")); tStatement.BindValue(iSQLiteColumnNumber++, pszValue ? pszValue : _T("")); break; } case IColumnsDefinition::eType_path: { const wchar_t* pszValue = (const wchar_t*)(unsigned long long*)GetDataForColumn(stColumn); - DBTRACE1_D(_T("- param(path): %s\n"), pszValue ? pszValue : _T("")); + LOG_TRACE(m_spLog) << L"BindValue - column: " << stColumn << L", value(path): " << (pszValue ? pszValue : _T("")); tStatement.BindValue(iSQLiteColumnNumber++, pszValue ? PathFromString(pszValue) : TSmartPath()); break; } @@ -532,11 +527,4 @@ FreeColumnData(stColumn); } } - - TSQLiteSerializerRowData& TSQLiteSerializerRowData::operator=(const TSQLiteSerializerRowData& rSrc) - { - m_pPoolMemory = rSrc.m_pPoolMemory; - - return *this; - } } Index: src/libchcore/TSQLiteSerializerRowData.h =================================================================== diff -u -r12ee49f6bf1f8921500ee2078e0a8c2d7b6d2a45 -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TSQLiteSerializerRowData.h (.../TSQLiteSerializerRowData.h) (revision 12ee49f6bf1f8921500ee2078e0a8c2d7b6d2a45) +++ src/libchcore/TSQLiteSerializerRowData.h (.../TSQLiteSerializerRowData.h) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -25,6 +25,7 @@ #include "TSQLiteDatabase.h" #include "TSQLiteStatement.h" #include +#include "../liblogger/TLogger.h" namespace chcore { @@ -35,14 +36,12 @@ private: static const unsigned long long AddedBit = 1; - private: - TSQLiteSerializerRowData(object_id_t oidRowID, TSQLiteColumnsDefinition& rColumnDefinition, bool bAdded, unsigned long long* pPoolMemory, size_t stPoolMemorySizeInBytes, TPlainStringPool& poolStrings); - public: - TSQLiteSerializerRowData(const TSQLiteSerializerRowData& rSrc); + TSQLiteSerializerRowData(object_id_t oidRowID, TSQLiteColumnsDefinition& rColumnDefinition, bool bAdded, unsigned long long* pPoolMemory, size_t stPoolMemorySizeInBytes, TPlainStringPool& poolStrings, const logger::TLogFileDataPtr& spLogFileData); + TSQLiteSerializerRowData(const TSQLiteSerializerRowData& rSrc) = delete; virtual ~TSQLiteSerializerRowData(); - TSQLiteSerializerRowData& operator=(const TSQLiteSerializerRowData& rSrc); + TSQLiteSerializerRowData& operator=(const TSQLiteSerializerRowData& rSrc) = delete; ISerializerRowData& SetValue(size_t stColIndex, bool bValue) override; ISerializerRowData& SetValue(size_t stColIndex, short iValue) override; @@ -97,6 +96,10 @@ TSQLiteColumnsDefinition& m_rColumns; TPlainStringPool& m_poolStrings; +#pragma warning(push) +#pragma warning(disable: 4251) + logger::TLoggerPtr m_spLog; +#pragma warning(pop) friend class TSQLiteSerializerContainer; }; Index: src/libchcore/TSQLiteSerializerRowReader.cpp =================================================================== diff -u -rd9527df01ee91b35d9a5fdccb80ded25a9c8265f -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TSQLiteSerializerRowReader.cpp (.../TSQLiteSerializerRowReader.cpp) (revision d9527df01ee91b35d9a5fdccb80ded25a9c8265f) +++ src/libchcore/TSQLiteSerializerRowReader.cpp (.../TSQLiteSerializerRowReader.cpp) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -23,15 +23,15 @@ #include "ErrorCodes.h" #include #include "TSQLiteStatement.h" -#include "SerializerTrace.h" namespace chcore { - TSQLiteSerializerRowReader::TSQLiteSerializerRowReader(const sqlite::TSQLiteDatabasePtr& spDatabase, TSQLiteColumnsDefinition& rColumns, const TString& strContainerName) : + TSQLiteSerializerRowReader::TSQLiteSerializerRowReader(const sqlite::TSQLiteDatabasePtr& spDatabase, TSQLiteColumnsDefinition& rColumns, const TString& strContainerName, const logger::TLogFileDataPtr& spLogFileData) : m_bInitialized(false), m_spStatement(new sqlite::TSQLiteStatement(spDatabase)), m_rColumns(rColumns), - m_strContainerName(strContainerName) + m_strContainerName(strContainerName), + m_spLog(logger::MakeLogger(spLogFileData, L"Serializer-RowReader")) { if (m_strContainerName.IsEmpty()) throw TCoreException(eErr_InvalidArgument, L"m_strContainerName", LOCATION); @@ -52,7 +52,7 @@ TString strQuery; strQuery = boost::str(boost::wformat(L"SELECT %1% FROM %2% ORDER BY id") % m_rColumns.GetCommaSeparatedColumns().c_str() % m_strContainerName.c_str()).c_str(); - DBTRACE1_D(_T("Executing query: %s\n"), strQuery.c_str()); + LOG_TRACE(m_spLog) << L"Executing query: " << strQuery; m_spStatement->Prepare(strQuery.c_str()); m_bInitialized = true; } Index: src/libchcore/TSQLiteSerializerRowReader.h =================================================================== diff -u -rb26ced3298e3e7e51d91f3ac70b56746786da83b -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TSQLiteSerializerRowReader.h (.../TSQLiteSerializerRowReader.h) (revision b26ced3298e3e7e51d91f3ac70b56746786da83b) +++ src/libchcore/TSQLiteSerializerRowReader.h (.../TSQLiteSerializerRowReader.h) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -22,13 +22,14 @@ #include "ISerializerRowReader.h" #include "TSQLiteStatement.h" #include "TSQLiteColumnDefinition.h" +#include "../liblogger/TLogger.h" namespace chcore { class LIBCHCORE_API TSQLiteSerializerRowReader : public ISerializerRowReader { public: - TSQLiteSerializerRowReader(const sqlite::TSQLiteDatabasePtr& spDatabase, TSQLiteColumnsDefinition& rColumns, const TString& strContainerName); + TSQLiteSerializerRowReader(const sqlite::TSQLiteDatabasePtr& spDatabase, TSQLiteColumnsDefinition& rColumns, const TString& strContainerName, const logger::TLogFileDataPtr& spLogFileData); TSQLiteSerializerRowReader(const TSQLiteSerializerRowReader&) = delete; virtual ~TSQLiteSerializerRowReader(); @@ -59,6 +60,7 @@ sqlite::TSQLiteStatementPtr m_spStatement; TSQLiteColumnsDefinition& m_rColumns; TString m_strContainerName; + logger::TLoggerPtr m_spLog; #pragma warning(pop) }; Index: src/libchcore/TSQLiteStatement.cpp =================================================================== diff -u -ra4635addad389b9e117679437a3e1b64a739ea96 -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TSQLiteStatement.cpp (.../TSQLiteStatement.cpp) (revision a4635addad389b9e117679437a3e1b64a739ea96) +++ src/libchcore/TSQLiteStatement.cpp (.../TSQLiteStatement.cpp) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -22,7 +22,6 @@ #include "ErrorCodes.h" #include "TSQLiteException.h" #include -#include "SerializerTrace.h" namespace chcore { @@ -40,10 +39,7 @@ TSQLiteStatement::~TSQLiteStatement() { int iResult = sqlite3_finalize(m_pStatement); - if(iResult != SQLITE_OK) - { - DBTRACE1(L"sqlite3_finalize failed with error code: %d", iResult); - } + _ASSERTE(iResult == SQLITE_OK); } void TSQLiteStatement::Close() Index: src/libchcore/TSQLiteTaskManagerSchema.cpp =================================================================== diff -u -ra4635addad389b9e117679437a3e1b64a739ea96 -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TSQLiteTaskManagerSchema.cpp (.../TSQLiteTaskManagerSchema.cpp) (revision a4635addad389b9e117679437a3e1b64a739ea96) +++ src/libchcore/TSQLiteTaskManagerSchema.cpp (.../TSQLiteTaskManagerSchema.cpp) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -46,7 +46,7 @@ { TSQLiteStatement tStatement(spDatabase); - tStatement.Prepare(_T("CREATE TABLE tasks(id BIGINT UNIQUE PRIMARY KEY, task_order INT NOT NULL, path VARCHAR(32768) NOT NULL)")); + tStatement.Prepare(_T("CREATE TABLE tasks(id BIGINT UNIQUE PRIMARY KEY, task_order INT NOT NULL, path VARCHAR(32768) NOT NULL, logpath VARCHAR(32768) NOT NULL)")); tStatement.Step(); // and finally set the database version to current one @@ -63,6 +63,26 @@ tVersion.SetVersion(2); } + if(tVersion.GetVersion() == 2) + { + TSQLiteStatement tStatement(spDatabase); + + tStatement.Prepare(_T("ALTER TABLE tasks RENAME TO tasks_old")); + tStatement.Step(); + + tStatement.Prepare(_T("CREATE TABLE tasks(id BIGINT UNIQUE PRIMARY KEY, task_order INT NOT NULL, path VARCHAR(32768) NOT NULL, logpath VARCHAR(32768) NOT NULL)")); + tStatement.Step(); + + + tStatement.Prepare(_T("INSERT INTO tasks(id, task_order, path, logpath) SELECT id, task_order, path, replace(path, '.sqlite', '.log') FROM tasks_old")); + tStatement.Step(); + + tStatement.Prepare(_T("DROP TABLE tasks_old")); + tStatement.Step(); + + tVersion.SetVersion(3); + } + tTransaction.Commit(); } } Index: src/libchcore/TSQLiteTaskSchema.cpp =================================================================== diff -u -ra4635addad389b9e117679437a3e1b64a739ea96 -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TSQLiteTaskSchema.cpp (.../TSQLiteTaskSchema.cpp) (revision a4635addad389b9e117679437a3e1b64a739ea96) +++ src/libchcore/TSQLiteTaskSchema.cpp (.../TSQLiteTaskSchema.cpp) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -59,6 +59,9 @@ if(tVersion.GetVersion() == 4) Migrate_004_005(spDatabase, tVersion); + + if(tVersion.GetVersion() == 5) + Migrate_005_006(spDatabase, tVersion); } tTransaction.Commit(); @@ -67,7 +70,7 @@ void TSQLiteTaskSchema::CreateNewDatabase(const sqlite::TSQLiteDatabasePtr& spDatabase, TSerializerVersion &tVersion) { sqlite::TSQLiteStatement tStatement(spDatabase); - tStatement.Prepare(_T("CREATE TABLE task(id BIGINT UNIQUE, name varchar(256) NOT NULL, log_path VARCHAR(32768), current_state INT NOT NULL, destination_path varchar(32768) NOT NULL)")); + tStatement.Prepare(_T("CREATE TABLE task(id BIGINT UNIQUE, name varchar(256) NOT NULL, current_state INT NOT NULL, destination_path varchar(32768) NOT NULL)")); tStatement.Step(); tStatement.Prepare(_T("CREATE TABLE base_paths(id BIGINT UNIQUE, src_path varchar(32768) NOT NULL, skip_processing boolean NOT NULL, dst_path varchar(32768) NOT NULL)")); @@ -235,4 +238,24 @@ tVersion.SetVersion(5); } + + void TSQLiteTaskSchema::Migrate_005_006(const sqlite::TSQLiteDatabasePtr& spDatabase, TSerializerVersion &tVersion) + { + sqlite::TSQLiteStatement tStatement(spDatabase); + + // remove column log_path + tStatement.Prepare(_T("ALTER TABLE task RENAME TO task_old")); + tStatement.Step(); + + tStatement.Prepare(_T("CREATE TABLE task(id BIGINT UNIQUE, name varchar(256) NOT NULL, current_state INT NOT NULL, destination_path varchar(32768) NOT NULL)")); + tStatement.Step(); + + tStatement.Prepare(_T("INSERT INTO task(id, name, current_state, destination_path) SELECT id, name, current_state, destination_path FROM task_old")); + tStatement.Step(); + + tStatement.Prepare(_T("DROP TABLE task_old")); + tStatement.Step(); + + tVersion.SetVersion(6); + } } Index: src/libchcore/TSQLiteTaskSchema.h =================================================================== diff -u -r12ee49f6bf1f8921500ee2078e0a8c2d7b6d2a45 -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TSQLiteTaskSchema.h (.../TSQLiteTaskSchema.h) (revision 12ee49f6bf1f8921500ee2078e0a8c2d7b6d2a45) +++ src/libchcore/TSQLiteTaskSchema.h (.../TSQLiteTaskSchema.h) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -40,6 +40,7 @@ void Migrate_002_003(const sqlite::TSQLiteDatabasePtr& spDatabase, TSerializerVersion &tVersion); void Migrate_003_004(const sqlite::TSQLiteDatabasePtr& spDatabase, TSerializerVersion &tVersion); void Migrate_004_005(const sqlite::TSQLiteDatabasePtr& spDatabase, TSerializerVersion &tVersion); + void Migrate_005_006(const sqlite::TSQLiteDatabasePtr& spDatabase, TSerializerVersion &tVersion); }; typedef std::shared_ptr TSQLiteTaskSchemaPtr; Index: src/libchcore/TTask.cpp =================================================================== diff -u -rd9527df01ee91b35d9a5fdccb80ded25a9c8265f -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TTask.cpp (.../TTask.cpp) (revision d9527df01ee91b35d9a5fdccb80ded25a9c8265f) +++ src/libchcore/TTask.cpp (.../TTask.cpp) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -28,7 +28,6 @@ #include "ErrorCodes.h" #include "ISerializerRowData.h" #include "TStringSet.h" -#include "SerializerTrace.h" #include "TScopedRunningTimeTracker.h" #include "TScopedRunningTimeTrackerPause.h" #include "TFeedbackHandlerWrapper.h" @@ -44,15 +43,15 @@ // TTask members TTask::TTask(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, - const TTaskDefinition& rTaskDefinition, const TSmartPath& rLogPath, const logger::TMultiLoggerConfigPtr& spLoggerConfig) : + const TTaskDefinition& rTaskDefinition, const logger::TLogFileDataPtr& spLogFileData) : m_spSerializer(spSerializer), m_spInternalFeedbackHandler(spFeedbackHandler), - m_spLog(std::make_unique(logger::TAsyncMultiLogger::GetInstance()->CreateLoggerData(rLogPath.ToString(), spLoggerConfig), L"Task")), + m_spLog(logger::MakeLogger(spLogFileData, L"Task")), m_spSrcPaths(new TBasePathDataContainer), m_tSubTasksArray(m_tSubTaskContext), m_tSubTaskContext(m_tConfiguration, m_spSrcPaths, m_afFilters, - m_cfgTracker, m_spLog->GetLogFileData(), m_workerThread, - std::make_shared(m_spLog->GetLogFileData())), + m_cfgTracker, spLogFileData, m_workerThread, + std::make_shared(spLogFileData)), m_bForce(false), m_bContinue(false) { @@ -61,14 +60,13 @@ if(!spSerializer) throw TCoreException(eErr_InvalidArgument, L"spSerializer", LOCATION); - m_tBaseData.SetLogPath(rLogPath); SetTaskDefinition(rTaskDefinition); } - TTask::TTask(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, const TTaskBaseData& rBaseTaskData, const logger::TMultiLoggerConfigPtr& spLoggerConfig) : + TTask::TTask(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, const logger::TLogFileDataPtr& spLogFileData) : m_spSerializer(spSerializer), m_spInternalFeedbackHandler(spFeedbackHandler), - m_spLog(std::make_unique(logger::TAsyncMultiLogger::GetInstance()->CreateLoggerData(rBaseTaskData.GetLogPath().ToString(), spLoggerConfig), L"Task")), + m_spLog(logger::MakeLogger(spLogFileData, L"Task")), m_spSrcPaths(new TBasePathDataContainer), m_tSubTasksArray(m_tSubTaskContext), m_tSubTaskContext(m_tConfiguration, m_spSrcPaths, m_afFilters, @@ -141,9 +139,8 @@ SetTaskPropValue(m_tConfiguration, nPriority); } - void TTask::Load(const TTaskBaseData& rBaseData) + void TTask::Load() { - bool bLogPathLoaded = false; bool bLoadFailed = false; const size_t stMaxSize = 1024; wchar_t szErr[stMaxSize]; @@ -153,10 +150,8 @@ boost::unique_lock lock(m_lock); ISerializerContainerPtr spContainer = m_spSerializer->GetContainer(_T("task")); - m_tBaseData = rBaseData;// .Load(spContainer); + m_tBaseData.Load(spContainer); - bLogPathLoaded = true; - spContainer = m_spSerializer->GetContainer(_T("base_paths")); m_spSrcPaths->Load(spContainer); @@ -202,38 +197,31 @@ { try { - if (bLogPathLoaded) - { - LOG_ERROR(m_spLog) << szErr; - } + LOG_ERROR(m_spLog) << szErr; } catch (const std::exception&) { } } } - TTaskPtr TTask::Load(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, const logger::TMultiLoggerConfigPtr& spLoggerConfig) + TTaskPtr TTask::Load(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, const logger::TLogFileDataPtr& spLogFileData) { - TTaskBaseData tBaseData; - ISerializerContainerPtr spContainer = spSerializer->GetContainer(_T("task")); - tBaseData.Load(spContainer); + TTaskPtr spTask = std::shared_ptr(new TTask(spSerializer, spFeedbackHandler, spLogFileData)); + spTask->Load(); - TTaskPtr spTask = std::shared_ptr(new TTask(spSerializer, spFeedbackHandler, tBaseData, spLoggerConfig)); - spTask->Load(tBaseData); - return spTask; } void TTask::Store(bool bForce) { if (GetTaskState() == eTaskState_LoadError) { - DBTRACE0(_T("Task::Store() - not storing task as it was not loaded correctly\n")); + LOG_DEBUG(m_spLog) << L"Task::Store() - not storing task as it was not loaded correctly"; return; } - DBTRACE0(_T("###### Task::Store() - starting\n")); + LOG_DEBUG(m_spLog) << L"Task::Store() - starting"; // ensure we're only running one serialization of this task at a time; // (this is usually called from the gui thread (on timer) and at specific points @@ -242,15 +230,15 @@ { if (!m_mutexSerializer.try_lock()) { - DBTRACE0(_T("###### Task::Store() - serialization already running. Skipping.\n")); + LOG_DEBUG(m_spLog) << L"Task::Store() - serialization already running. Skipping."; return; } } else { if (!m_mutexSerializer.try_lock()) { - DBTRACE0(_T("###### Task::Store() - waiting for serialization mutex...\n")); + LOG_DEBUG(m_spLog) << L"Task::Store() - waiting for serialization mutex..."; m_mutexSerializer.lock(); } } @@ -294,7 +282,7 @@ m_spSerializer->Flush(); unsigned long long ullFlushTime = timer.Stop(); ullFlushTime; - DBTRACE2(_T("###### Task::Store() - finished - gather: %I64u ms, flush: %I64u ms\n"), ullGatherTime, ullFlushTime); + LOG_DEBUG(m_spLog) << L"Task::Store() - finished - gather: " << ullGatherTime << L" ms, flush: " << ullFlushTime << L" ms"; } void TTask::KillThread() @@ -715,7 +703,8 @@ TSmartPath TTask::GetLogPath() const { - return m_tBaseData.GetLogPath(); + std::wstring wstrPath = m_spLog->GetLogFilePath(); + return PathFromString(wstrPath.c_str()); } void TTask::GetLogPaths(logger::TLoggerPaths& rLogPaths) const @@ -729,11 +718,6 @@ return m_tBaseData.GetTaskName(); } - void TTask::SetLogPath(const TSmartPath& pathLog) - { - m_tBaseData.SetLogPath(pathLog); - } - ISerializerPtr TTask::GetSerializer() const { return m_spSerializer; Index: src/libchcore/TTask.h =================================================================== diff -u -rb26ced3298e3e7e51d91f3ac70b56746786da83b -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TTask.h (.../TTask.h) (revision b26ced3298e3e7e51d91f3ac70b56746786da83b) +++ src/libchcore/TTask.h (.../TTask.h) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -48,8 +48,8 @@ { private: TTask(const TTask&) = delete; - TTask(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, const TTaskBaseData& rBaseTaskData, const logger::TMultiLoggerConfigPtr& spLoggerConfig); - TTask(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, const TTaskDefinition& rTaskDefinition, const TSmartPath& rLogPath, const logger::TMultiLoggerConfigPtr& spLoggerConfig); + TTask(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, const logger::TLogFileDataPtr& spLogFileData); + TTask(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, const TTaskDefinition& rTaskDefinition, const logger::TLogFileDataPtr& spLogFileData); TTask& operator=(const TTask&) = delete; @@ -72,7 +72,7 @@ // thread void SetPriority(int nPriority); - static TTaskPtr Load(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, const logger::TMultiLoggerConfigPtr& spLoggerConfig); + static TTaskPtr Load(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, const logger::TLogFileDataPtr& spLogFileData); void Store(bool bForce); void BeginProcessing(); @@ -91,12 +91,10 @@ void RestoreFeedbackDefaults(); private: - void Load(const TTaskBaseData& rBaseData); + void Load(); void SetTaskDefinition(const TTaskDefinition& rTaskDefinition); - void SetLogPath(const TSmartPath& pathLog); - // methods are called when task is being added or removed from the global task array /// Method is called when this task is being added to a TTaskManager object void OnRegisterTask(); Index: src/libchcore/TTaskBaseData.cpp =================================================================== diff -u -ra4635addad389b9e117679437a3e1b64a739ea96 -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TTaskBaseData.cpp (.../TTaskBaseData.cpp) (revision a4635addad389b9e117679437a3e1b64a739ea96) +++ src/libchcore/TTaskBaseData.cpp (.../TTaskBaseData.cpp) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -28,7 +28,6 @@ TTaskBaseData::TTaskBaseData() : m_strTaskName(m_setChanges), m_eCurrentState(m_setChanges), - m_pathLog(m_setChanges), m_pathDestinationPath(m_setChanges) { m_setChanges[eMod_Added] = true; @@ -58,16 +57,6 @@ m_eCurrentState = eCurrentState; } - TSmartPath TTaskBaseData::GetLogPath() const - { - return m_pathLog; - } - - void TTaskBaseData::SetLogPath(const TSmartPath& pathLog) - { - m_pathLog = pathLog; - } - TSmartPath TTaskBaseData::GetDestinationPath() const { return m_pathDestinationPath; @@ -92,9 +81,6 @@ if (bAdded || m_setChanges[eMod_TaskName]) rRow.SetValue(_T("name"), m_strTaskName); - if (bAdded || m_setChanges[eMod_LogPath]) - rRow.SetValue(_T("log_path"), m_pathLog); - if (bAdded || m_setChanges[eMod_CurrentState]) rRow.SetValue(_T("current_state"), m_eCurrentState); @@ -115,7 +101,6 @@ if (bResult) { spRowReader->GetValue(_T("name"), m_strTaskName.Modify()); - spRowReader->GetValue(_T("log_path"), m_pathLog.Modify()); spRowReader->GetValue(_T("current_state"), *(int*)(ETaskCurrentState*)&m_eCurrentState.Modify()); spRowReader->GetValue(_T("destination_path"), m_pathDestinationPath.Modify()); } @@ -132,7 +117,6 @@ { rColumns.AddColumn(_T("id"), ColumnType::value); rColumns.AddColumn(_T("name"), IColumnsDefinition::eType_string); - rColumns.AddColumn(_T("log_path"), IColumnsDefinition::eType_path); rColumns.AddColumn(_T("current_state"), IColumnsDefinition::eType_int); rColumns.AddColumn(_T("destination_path"), IColumnsDefinition::eType_path); } Index: src/libchcore/TTaskBaseData.h =================================================================== diff -u -rb26ced3298e3e7e51d91f3ac70b56746786da83b -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TTaskBaseData.h (.../TTaskBaseData.h) (revision b26ced3298e3e7e51d91f3ac70b56746786da83b) +++ src/libchcore/TTaskBaseData.h (.../TTaskBaseData.h) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -38,9 +38,6 @@ ETaskCurrentState GetCurrentState() const; void SetCurrentState(ETaskCurrentState eCurrentState); - TSmartPath GetLogPath() const; - void SetLogPath(const TSmartPath& pathLog); - TSmartPath GetDestinationPath() const; void SetDestinationPath(const TSmartPath& pathDst); @@ -55,7 +52,6 @@ eMod_Added, eMod_TaskName, eMod_CurrentState, - eMod_LogPath, eMod_DstPath, eMod_Last @@ -68,7 +64,6 @@ TSharedModificationTracker m_strTaskName; TSharedModificationTracker m_eCurrentState; // current state of processing this task represents - TSharedModificationTracker m_pathLog; TSharedModificationTracker m_pathDestinationPath; #pragma warning(pop) }; Index: src/libchcore/TTaskInfo.cpp =================================================================== diff -u -rd9527df01ee91b35d9a5fdccb80ded25a9c8265f -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TTaskInfo.cpp (.../TTaskInfo.cpp) (revision d9527df01ee91b35d9a5fdccb80ded25a9c8265f) +++ src/libchcore/TTaskInfo.cpp (.../TTaskInfo.cpp) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -27,14 +27,16 @@ TTaskInfoEntry::TTaskInfoEntry() : m_oidObjectID(0), m_pathSerializeLocation(m_setModifications), + m_pathLogPath(m_setModifications), m_iOrder(m_setModifications, 0) { m_setModifications[eMod_Added] = true; } - TTaskInfoEntry::TTaskInfoEntry(object_id_t oidTaskID, const TSmartPath& pathTask, int iOrder, const TTaskPtr& spTask) : + TTaskInfoEntry::TTaskInfoEntry(object_id_t oidTaskID, const TSmartPath& pathTask, const TSmartPath& pathLog, int iOrder, const TTaskPtr& spTask) : m_oidObjectID(oidTaskID), m_pathSerializeLocation(m_setModifications, pathTask), + m_pathLogPath(m_setModifications, pathLog), m_iOrder(m_setModifications, iOrder), m_spTask(spTask) { @@ -45,6 +47,7 @@ m_oidObjectID(rSrc.m_oidObjectID), m_setModifications(rSrc.m_setModifications), m_pathSerializeLocation(m_setModifications, rSrc.m_pathSerializeLocation), + m_pathLogPath(m_setModifications, rSrc.m_pathLogPath), m_iOrder(m_setModifications, rSrc.m_iOrder), m_spTask(rSrc.m_spTask) { @@ -56,6 +59,7 @@ { m_oidObjectID = rSrc.m_oidObjectID; m_pathSerializeLocation = rSrc.m_pathSerializeLocation; + m_pathLogPath = rSrc.m_pathLogPath; m_iOrder = rSrc.m_iOrder; m_spTask = rSrc.m_spTask; m_setModifications = rSrc.m_setModifications; @@ -74,6 +78,16 @@ m_pathSerializeLocation = strTaskPath; } + TSmartPath TTaskInfoEntry::GetTaskLogPath() const + { + return m_pathLogPath; + } + + void TTaskInfoEntry::SetTaskLogPath(const TSmartPath& pathLog) + { + m_pathLogPath = pathLog; + } + TTaskPtr TTaskInfoEntry::GetTask() const { return m_spTask; @@ -104,6 +118,8 @@ if (bAdded || m_setModifications[eMod_TaskPath]) rRow.SetValue(_T("path"), m_pathSerializeLocation); + if (bAdded || m_setModifications[eMod_LogPath]) + rRow.SetValue(_T("logpath"), m_pathLogPath); if (bAdded || m_setModifications[eMod_Order]) rRow.SetValue(_T("task_order"), m_iOrder); @@ -114,6 +130,7 @@ { spRowReader->GetValue(_T("id"), m_oidObjectID); spRowReader->GetValue(_T("path"), m_pathSerializeLocation.Modify()); + spRowReader->GetValue(_T("logpath"), m_pathLogPath.Modify()); spRowReader->GetValue(_T("task_order"), m_iOrder.Modify()); m_setModifications.reset(); @@ -123,6 +140,7 @@ { rColumnDefs.AddColumn(_T("id"), ColumnType::value); rColumnDefs.AddColumn(_T("path"), IColumnsDefinition::eType_path); + rColumnDefs.AddColumn(_T("logpath"), IColumnsDefinition::eType_path); rColumnDefs.AddColumn(_T("task_order"), IColumnsDefinition::eType_int); } @@ -142,9 +160,9 @@ { } - void TTaskInfoContainer::Add(const TSmartPath& pathTask, int iOrder, const TTaskPtr& spTask) + void TTaskInfoContainer::Add(const TSmartPath& pathTask, const TSmartPath& pathLog, int iOrder, const TTaskPtr& spTask) { - m_vTaskInfos.push_back(TTaskInfoEntry(++m_oidLastObjectID, pathTask, iOrder, spTask)); + m_vTaskInfos.push_back(TTaskInfoEntry(++m_oidLastObjectID, pathTask, pathLog, iOrder, spTask)); } void TTaskInfoContainer::RemoveAt(size_t stIndex) Index: src/libchcore/TTaskInfo.h =================================================================== diff -u -rb26ced3298e3e7e51d91f3ac70b56746786da83b -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TTaskInfo.h (.../TTaskInfo.h) (revision b26ced3298e3e7e51d91f3ac70b56746786da83b) +++ src/libchcore/TTaskInfo.h (.../TTaskInfo.h) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -40,13 +40,14 @@ eMod_Added, eMod_TaskPath, eMod_Order, + eMod_LogPath, eMod_Last }; public: TTaskInfoEntry(); - TTaskInfoEntry(object_id_t oidTaskID, const TSmartPath& pathTask, int iOrder, const TTaskPtr& spTask); + TTaskInfoEntry(object_id_t oidTaskID, const TSmartPath& pathTask, const TSmartPath& pathLog, int iOrder, const TTaskPtr& spTask); TTaskInfoEntry(const TTaskInfoEntry& rSrc); TTaskInfoEntry& operator=(const TTaskInfoEntry& rSrc); @@ -56,6 +57,9 @@ TSmartPath GetTaskSerializeLocation() const; void SetTaskSerializeLocation(const TSmartPath& pathTask); + TSmartPath GetTaskLogPath() const; + void SetTaskLogPath(const TSmartPath& pathLog); + TTaskPtr GetTask() const; void SetTask(const TTaskPtr& spTask); @@ -75,6 +79,7 @@ typedef std::bitset Bitset; mutable std::bitset m_setModifications; TSharedModificationTracker m_pathSerializeLocation; + TSharedModificationTracker m_pathLogPath; TSharedModificationTracker m_iOrder; TTaskPtr m_spTask; @@ -89,7 +94,7 @@ TTaskInfoContainer& operator=(const TTaskInfoContainer&) = delete; - void Add(const TSmartPath& strPath, int iOrder, const TTaskPtr& spTask); + void Add(const TSmartPath& strPath, const TSmartPath& pathLog, int iOrder, const TTaskPtr& spTask); void RemoveAt(size_t stIndex); TTaskInfoEntry& GetAt(size_t stIndex); Index: src/libchcore/TTaskManager.cpp =================================================================== diff -u -rb26ced3298e3e7e51d91f3ac70b56746786da83b -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TTaskManager.cpp (.../TTaskManager.cpp) (revision b26ced3298e3e7e51d91f3ac70b56746786da83b) +++ src/libchcore/TTaskManager.cpp (.../TTaskManager.cpp) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -25,9 +25,9 @@ #include "TCoreException.h" #include "ErrorCodes.h" #include "TTaskInfo.h" -#include "SerializerTrace.h" #include "TFakeFileSerializer.h" #include "../liblogger/TLoggerPaths.h" +#include "../liblogger/TAsyncMultiLogger.h" namespace chcore { @@ -37,11 +37,13 @@ const IFeedbackHandlerFactoryPtr& spFeedbackHandlerFactory, const TSmartPath& pathLogDir, const logger::TMultiLoggerConfigPtr& spMultiLoggerConfig, + const logger::TLogFileDataPtr& spLogFileData, bool bForceRecreateSerializer) : m_pathLogDir(pathLogDir), m_spFeedbackFactory(spFeedbackHandlerFactory), m_spSerializerFactory(spSerializerFactory), - m_spMultiLoggerConfig(spMultiLoggerConfig) + m_spMultiLoggerConfig(spMultiLoggerConfig), + m_spLog(logger::MakeLogger(spLogFileData, L"TaskManager")) { if(!spFeedbackHandlerFactory) throw TCoreException(eErr_InvalidPointer, L"spFeedbackHandlerFactory", LOCATION); @@ -60,10 +62,13 @@ TTaskPtr TTaskManager::CreateTask(const TTaskDefinition& tTaskDefinition) { IFeedbackHandlerPtr spHandler = m_spFeedbackFactory->Create(); - ISerializerPtr spSerializer = m_spSerializerFactory->CreateTaskSerializer(tTaskDefinition.GetTaskName()); + TSmartPath pathLog = CreateTaskLogPath(tTaskDefinition.GetTaskName()); + logger::TLogFileDataPtr spLogFileData = logger::TAsyncMultiLogger::GetInstance()->CreateLoggerData(pathLog.ToString(), m_spMultiLoggerConfig); - TTaskPtr spTask(new TTask(spSerializer, spHandler, tTaskDefinition, CreateTaskLogPath(tTaskDefinition.GetTaskName()), m_spMultiLoggerConfig)); + ISerializerPtr spSerializer = m_spSerializerFactory->CreateTaskSerializer(spLogFileData, tTaskDefinition.GetTaskName()); + TTaskPtr spTask(new TTask(spSerializer, spHandler, tTaskDefinition, spLogFileData)); + spTask->Store(true); Add(spTask); @@ -131,7 +136,7 @@ iOrder = rEntry.GetOrder() + 1; } - m_tTasks.Add(spNewTask->GetSerializer()->GetLocation(), iOrder, spNewTask); + m_tTasks.Add(spNewTask->GetSerializer()->GetLocation(), spNewTask->GetLogPath(), iOrder, spNewTask); spNewTask->OnRegisterTask(); } @@ -470,7 +475,7 @@ m_spSerializer->Flush(); unsigned long long ullFlushTime = timer.Stop(); ullFlushTime; - DBTRACE2(_T("TaskManager::Store() - gather: %I64u ms, flush: %I64u ms\n"), ullGatherTime, ullFlushTime); + //DBTRACE2(_T("TaskManager::Store() - gather: %I64u ms, flush: %I64u ms\n"), ullGatherTime, ullFlushTime); } void TTaskManager::Load() @@ -495,15 +500,15 @@ } // retrieve information about tasks to load - std::vector > vObjects; + std::vector > vObjects; { boost::shared_lock lock(m_lock); for (size_t stIndex = 0; stIndex < m_tTasks.GetCount(); ++stIndex) { TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); if (!rEntry.GetTask()) - vObjects.push_back(std::make_pair(rEntry.GetObjectID(), rEntry.GetTaskSerializeLocation())); + vObjects.push_back(std::make_tuple(rEntry.GetObjectID(), rEntry.GetTaskSerializeLocation(), rEntry.GetTaskLogPath())); } } @@ -512,30 +517,34 @@ IFeedbackHandlerPtr spHandler = m_spFeedbackFactory->Create(); ISerializerPtr spSerializer; + TString pathLog = std::get<2>(rInfo).ToWString(); + TString pathSerializer = std::get<1>(rInfo).ToWString(); + logger::TLogFileDataPtr spLogFileData = logger::TAsyncMultiLogger::GetInstance()->CreateLoggerData(pathLog.c_str(), m_spMultiLoggerConfig); + try { - spSerializer = m_spSerializerFactory->CreateTaskSerializer(rInfo.second.ToWString()); + spSerializer = m_spSerializerFactory->CreateTaskSerializer(spLogFileData, pathSerializer); } catch (const std::exception&) { // ignore the exception } if (!spSerializer) - spSerializer = std::make_shared(rInfo.second); + spSerializer = std::make_shared(std::get<1>(rInfo)); - TTaskPtr spTask = TTask::Load(spSerializer, spHandler, m_spMultiLoggerConfig); + TTaskPtr spTask = TTask::Load(spSerializer, spHandler, spLogFileData); boost::unique_lock lock(m_lock); - TTaskInfoEntry& rInfoEntry = m_tTasks.GetAtOid(rInfo.first); + TTaskInfoEntry& rInfoEntry = m_tTasks.GetAtOid(std::get<0>(rInfo)); rInfoEntry.SetTask(spTask); } } TSmartPath TTaskManager::CreateTaskLogPath(const TString& strTaskUuid) const { - TSmartPath pathLog = m_pathLogDir + PathFromWString(TString(_T("Task-")) + strTaskUuid + _T(".log")); + TSmartPath pathLog = m_pathLogDir + PathFromWString(TString(strTaskUuid + _T(".log"))); return pathLog; } Index: src/libchcore/TTaskManager.h =================================================================== diff -u -rb26ced3298e3e7e51d91f3ac70b56746786da83b -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/TTaskManager.h (.../TTaskManager.h) (revision b26ced3298e3e7e51d91f3ac70b56746786da83b) +++ src/libchcore/TTaskManager.h (.../TTaskManager.h) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -27,6 +27,7 @@ #include "ISerializerFactory.h" #include "TObsoleteFiles.h" #include "../liblogger/TMultiLoggerConfig.h" +#include "../liblogger/TLogger.h" namespace chcore { @@ -43,6 +44,7 @@ const IFeedbackHandlerFactoryPtr& spFeedbackHandlerFactory, const TSmartPath& pathLogDir, const logger::TMultiLoggerConfigPtr& spMultiLoggerConfig, + const logger::TLogFileDataPtr& spLogFileData, bool bForceRecreateSerializer = false); TTaskManager(const TTaskManager&) = delete; @@ -107,6 +109,7 @@ ISerializerPtr m_spSerializer; ISerializerFactoryPtr m_spSerializerFactory; logger::TMultiLoggerConfigPtr m_spMultiLoggerConfig; + logger::TLoggerPtr m_spLog; #pragma warning(pop) }; Index: src/libchcore/libchcore.vc140.vcxproj =================================================================== diff -u -r2dead97186004ce0d82ba8bb67f72db255fea090 -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/libchcore.vc140.vcxproj (.../libchcore.vc140.vcxproj) (revision 2dead97186004ce0d82ba8bb67f72db255fea090) +++ src/libchcore/libchcore.vc140.vcxproj (.../libchcore.vc140.vcxproj) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -500,7 +500,6 @@ - Index: src/libchcore/libchcore.vc140.vcxproj.filters =================================================================== diff -u -r2dead97186004ce0d82ba8bb67f72db255fea090 -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/libchcore/libchcore.vc140.vcxproj.filters (.../libchcore.vc140.vcxproj.filters) (revision 2dead97186004ce0d82ba8bb67f72db255fea090) +++ src/libchcore/libchcore.vc140.vcxproj.filters (.../libchcore.vc140.vcxproj.filters) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -60,9 +60,6 @@ {30d60be9-a936-4191-a66d-64e127f3d258} - - {49c9ae7e-1bc4-4875-8512-e92e0c00fb19} - {02c88ac8-15f7-4372-9f47-247ecbada7db} @@ -386,9 +383,6 @@ Source Files\Tools - - Source Files\Tools\DebugTrace - Source Files\Task Config Index: src/liblogger/TLogFileData.cpp =================================================================== diff -u -ra4635addad389b9e117679437a3e1b64a739ea96 -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/liblogger/TLogFileData.cpp (.../TLogFileData.cpp) (revision a4635addad389b9e117679437a3e1b64a739ea96) +++ src/liblogger/TLogFileData.cpp (.../TLogFileData.cpp) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -56,6 +56,13 @@ rLoggerPaths.Add(m_spLogFile->GetLogPath().c_str()); } + TLoggerPaths TLogFileData::GetMainLogPath() const + { + TLoggerPaths loggerPaths; + loggerPaths.Add(m_spLogFile->GetLogPath().c_str()); + return loggerPaths; + } + std::shared_ptr TLogFileData::GetEntriesEvent() const { return m_spHasEntriesEvent; Index: src/liblogger/TLogFileData.h =================================================================== diff -u -ra4635addad389b9e117679437a3e1b64a739ea96 -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/liblogger/TLogFileData.h (.../TLogFileData.h) (revision a4635addad389b9e117679437a3e1b64a739ea96) +++ src/liblogger/TLogFileData.h (.../TLogFileData.h) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -37,7 +37,9 @@ TLogFileData(PCTSTR pszLogPath, const TMultiLoggerConfigPtr& spLoggerConfig, const TLoggerRotationInfoPtr& spRotationInfo); TMultiLoggerConfigPtr GetMultiLoggerConfig() const; + void GetAllLogPaths(TLoggerPaths& rLoggerPaths) const; + TLoggerPaths GetMainLogPath() const; private: void PushLogEntry(std::wstring strLine); Index: src/liblogger/TLogger.h =================================================================== diff -u -rd9527df01ee91b35d9a5fdccb80ded25a9c8265f -re98c03b108baad889dfd7c7fbb1a49f5ea5a55d8 --- src/liblogger/TLogger.h (.../TLogger.h) (revision d9527df01ee91b35d9a5fdccb80ded25a9c8265f) +++ src/liblogger/TLogger.h (.../TLogger.h) (revision e98c03b108baad889dfd7c7fbb1a49f5ea5a55d8) @@ -25,6 +25,7 @@ #include "SeverityLevels.h" #include "TMultiLoggerConfig.h" #include "TLogRecord.h" +#include "TLoggerPaths.h" namespace logger { @@ -37,6 +38,8 @@ ESeverityLevel GetMinSeverity() const; TLogRecord OpenLogRecord(ESeverityLevel eLevel) const; + std::wstring GetLogFilePath() const; + private: TLoggerLevelConfigPtr m_spLoggerConfig; TLogFileDataPtr m_spFileData; @@ -52,6 +55,8 @@ { if(!spFileData) throw std::invalid_argument("spFileData"); + if(!m_spLoggerConfig) + throw std::invalid_argument("m_spLoggerConfig"); } inline TLogFileDataPtr TLogger::GetLogFileData() const @@ -69,10 +74,21 @@ return TLogRecord(m_spFileData, eLevel, m_strChannel); } + inline std::wstring TLogger::GetLogFilePath() const + { + TLoggerPaths loggerPaths = m_spFileData->GetMainLogPath(); + if(loggerPaths.GetCount() == 0) + throw std::invalid_argument(""); + return loggerPaths.GetAt(0); + } + using TLoggerPtr = std::unique_ptr; inline TLoggerPtr MakeLogger(const TLogFileDataPtr& spFileData, PCTSTR pszChannel) { + if (!spFileData) + throw std::invalid_argument("spFileData"); + return std::make_unique(spFileData, pszChannel); } }