Index: src/libchcore/TTask.cpp =================================================================== diff -u -rf8fcbbd1d2321cf0c8be79526c449384af654e49 -rde48778626a2e3f6a09a43f0211b2a04eba36fed --- src/libchcore/TTask.cpp (.../TTask.cpp) (revision f8fcbbd1d2321cf0c8be79526c449384af654e49) +++ src/libchcore/TTask.cpp (.../TTask.cpp) (revision de48778626a2e3f6a09a43f0211b2a04eba36fed) @@ -722,6 +722,12 @@ return m_tBaseData.GetLogPath(); } + void TTask::GetLogPaths(logger::TLoggerPaths& rLogPaths) const + { + logger::TLogFileDataPtr spFileData = m_spLog->GetLogFileData(); + spFileData->GetAllLogPaths(rLogPaths); + } + TString TTask::GetTaskName() const { return m_tBaseData.GetTaskName(); Index: src/libchcore/TTask.h =================================================================== diff -u -r12b36349f6214befeace08efa9acc7e03be0d847 -rde48778626a2e3f6a09a43f0211b2a04eba36fed --- src/libchcore/TTask.h (.../TTask.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) +++ src/libchcore/TTask.h (.../TTask.h) (revision de48778626a2e3f6a09a43f0211b2a04eba36fed) @@ -64,6 +64,7 @@ void GetBufferSizes(TBufferSizes& bsSizes); TSmartPath GetLogPath() const; + void GetLogPaths(logger::TLoggerPaths& rLogPaths) const; TString GetTaskName() const; // thread Index: src/libchcore/TTaskManager.cpp =================================================================== diff -u -r8a2ff3b2b71b45fb525e030167e62f316cb32869 -rde48778626a2e3f6a09a43f0211b2a04eba36fed --- src/libchcore/TTaskManager.cpp (.../TTaskManager.cpp) (revision 8a2ff3b2b71b45fb525e030167e62f316cb32869) +++ src/libchcore/TTaskManager.cpp (.../TTaskManager.cpp) (revision de48778626a2e3f6a09a43f0211b2a04eba36fed) @@ -27,6 +27,7 @@ #include "TTaskInfo.h" #include "SerializerTrace.h" #include "TFakeFileSerializer.h" +#include "..\liblogger\TLoggerPaths.h" namespace chcore { @@ -174,8 +175,7 @@ spTask->OnUnregisterTask(); - m_tObsoleteFiles.DeleteObsoleteFile(spTask->GetSerializer()->GetLocation()); - m_tObsoleteFiles.DeleteObsoleteFile(spTask->GetLogPath()); + RemoveFilesForTask(spTask); m_tTasks.RemoveAt(stIndex); } @@ -208,8 +208,7 @@ spTask->OnUnregisterTask(); - m_tObsoleteFiles.DeleteObsoleteFile(spTask->GetSerializer()->GetLocation()); - m_tObsoleteFiles.DeleteObsoleteFile(spTask->GetLogPath()); + RemoveFilesForTask(spTask); m_tTasks.RemoveAt(stIndex); } @@ -539,4 +538,16 @@ TSmartPath pathLog = m_pathLogDir + PathFromWString(TString(_T("Task-")) + strTaskUuid + _T(".log")); return pathLog; } + + void TTaskManager::RemoveFilesForTask(const TTaskPtr& spTask) + { + m_tObsoleteFiles.DeleteObsoleteFile(spTask->GetSerializer()->GetLocation()); + + logger::TLoggerPaths logPaths; + spTask->GetLogPaths(logPaths); + for(size_t stLogIndex = 0; stLogIndex != logPaths.GetCount(); ++stLogIndex) + { + m_tObsoleteFiles.DeleteObsoleteFile(PathFromString(logPaths.GetAt(stLogIndex))); + } + } } Index: src/libchcore/TTaskManager.h =================================================================== diff -u -r12b36349f6214befeace08efa9acc7e03be0d847 -rde48778626a2e3f6a09a43f0211b2a04eba36fed --- src/libchcore/TTaskManager.h (.../TTaskManager.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) +++ src/libchcore/TTaskManager.h (.../TTaskManager.h) (revision de48778626a2e3f6a09a43f0211b2a04eba36fed) @@ -85,6 +85,7 @@ void StopAllTasksNL(); TSmartPath CreateTaskLogPath(const TString& strTaskUuid) const; + void RemoveFilesForTask(const TTaskPtr& spTask); private: #pragma warning(push) Index: src/liblogger/TLogFile.cpp =================================================================== diff -u -rdd968ff1af628b1914a26fc1ad6170c55c5520ed -rde48778626a2e3f6a09a43f0211b2a04eba36fed --- src/liblogger/TLogFile.cpp (.../TLogFile.cpp) (revision dd968ff1af628b1914a26fc1ad6170c55c5520ed) +++ src/liblogger/TLogFile.cpp (.../TLogFile.cpp) (revision de48778626a2e3f6a09a43f0211b2a04eba36fed) @@ -83,6 +83,16 @@ m_spFileHandle.reset(); } + const std::vector& TLogFile::GetRotatedLogs() const + { + return m_vRotatedFiles; + } + + std::wstring TLogFile::GetLogPath() const + { + return m_strLogPath; + } + HANDLE TLogFile::GetFileHandle() { if (m_spFileHandle != nullptr) Index: src/liblogger/TLogFile.h =================================================================== diff -u -r545098ae76e9ce23598d37d2bee4020d6cb59f3c -rde48778626a2e3f6a09a43f0211b2a04eba36fed --- src/liblogger/TLogFile.h (.../TLogFile.h) (revision 545098ae76e9ce23598d37d2bee4020d6cb59f3c) +++ src/liblogger/TLogFile.h (.../TLogFile.h) (revision de48778626a2e3f6a09a43f0211b2a04eba36fed) @@ -40,6 +40,9 @@ void CloseIfUnused(); void CloseLogFile(); + const std::vector& GetRotatedLogs() const; + std::wstring GetLogPath() const; + private: HANDLE GetFileHandle(); unsigned long long GetCurrentLogSize(); Index: src/liblogger/TLogFileData.cpp =================================================================== diff -u -rebc7fabbd2d59f9a0f723ea480b5374cc393ec12 -rde48778626a2e3f6a09a43f0211b2a04eba36fed --- src/liblogger/TLogFileData.cpp (.../TLogFileData.cpp) (revision ebc7fabbd2d59f9a0f723ea480b5374cc393ec12) +++ src/liblogger/TLogFileData.cpp (.../TLogFileData.cpp) (revision de48778626a2e3f6a09a43f0211b2a04eba36fed) @@ -18,6 +18,7 @@ // ============================================================================ #include "stdafx.h" #include "TLogFileData.h" +#include "TLoggerPaths.h" namespace logger { @@ -44,6 +45,17 @@ return m_spLoggerConfig; } + void TLogFileData::GetAllLogPaths(TLoggerPaths& rLoggerPaths) const + { + rLoggerPaths.Clear(); + + for(const std::wstring& strPath : m_spLogFile->GetRotatedLogs()) + { + rLoggerPaths.Add(strPath.c_str()); + } + rLoggerPaths.Add(m_spLogFile->GetLogPath().c_str()); + } + std::shared_ptr TLogFileData::GetEntriesEvent() const { return m_spHasEntriesEvent; Index: src/liblogger/TLogFileData.h =================================================================== diff -u -r4a4360ee83d1051b3bfa3c42f93ca581b81d1744 -rde48778626a2e3f6a09a43f0211b2a04eba36fed --- src/liblogger/TLogFileData.h (.../TLogFileData.h) (revision 4a4360ee83d1051b3bfa3c42f93ca581b81d1744) +++ src/liblogger/TLogFileData.h (.../TLogFileData.h) (revision de48778626a2e3f6a09a43f0211b2a04eba36fed) @@ -28,13 +28,16 @@ namespace logger { + class TLoggerPaths; + class LIBLOGGER_API TLogFileData { public: TLogFileData(); TLogFileData(PCTSTR pszLogPath, const TMultiLoggerConfigPtr& spLoggerConfig, const TLoggerRotationInfoPtr& spRotationInfo); TMultiLoggerConfigPtr GetMultiLoggerConfig() const; + void GetAllLogPaths(TLoggerPaths& rLoggerPaths) const; private: void PushLogEntry(std::wstring strLine); Index: src/liblogger/TLoggerPaths.cpp =================================================================== diff -u --- src/liblogger/TLoggerPaths.cpp (revision 0) +++ src/liblogger/TLoggerPaths.cpp (revision de48778626a2e3f6a09a43f0211b2a04eba36fed) @@ -0,0 +1,43 @@ +// ============================================================================ +// Copyright (C) 2001-2016 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#include "stdafx.h" +#include "TLoggerPaths.h" + +namespace logger +{ + void TLoggerPaths::Add(PCTSTR pszPath) + { + m_vPaths.emplace_back(pszPath); + } + + size_t TLoggerPaths::GetCount() const + { + return m_vPaths.size(); + } + + PCTSTR TLoggerPaths::GetAt(size_t stIndex) const + { + return m_vPaths.at(stIndex).c_str(); + } + + void TLoggerPaths::Clear() + { + m_vPaths.clear(); + } +} Index: src/liblogger/TLoggerPaths.h =================================================================== diff -u --- src/liblogger/TLoggerPaths.h (revision 0) +++ src/liblogger/TLoggerPaths.h (revision de48778626a2e3f6a09a43f0211b2a04eba36fed) @@ -0,0 +1,43 @@ +// ============================================================================ +// Copyright (C) 2001-2016 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#ifndef __TLOGGERPATHS_H__ +#define __TLOGGERPATHS_H__ + +#include "liblogger.h" +#include + +namespace logger +{ + class LIBLOGGER_API TLoggerPaths + { + public: + void Add(PCTSTR pszPath); + size_t GetCount() const; + PCTSTR GetAt(size_t stIndex) const; + void Clear(); + + private: +#pragma warning(push) +#pragma warning(disable: 4251) + std::vector m_vPaths; +#pragma warning(pop) + }; +} + +#endif Index: src/liblogger/liblogger.vc140.vcxproj =================================================================== diff -u -r545098ae76e9ce23598d37d2bee4020d6cb59f3c -rde48778626a2e3f6a09a43f0211b2a04eba36fed --- src/liblogger/liblogger.vc140.vcxproj (.../liblogger.vc140.vcxproj) (revision 545098ae76e9ce23598d37d2bee4020d6cb59f3c) +++ src/liblogger/liblogger.vc140.vcxproj (.../liblogger.vc140.vcxproj) (revision de48778626a2e3f6a09a43f0211b2a04eba36fed) @@ -463,6 +463,7 @@ + @@ -498,6 +499,7 @@ + Index: src/liblogger/liblogger.vc140.vcxproj.filters =================================================================== diff -u -r545098ae76e9ce23598d37d2bee4020d6cb59f3c -rde48778626a2e3f6a09a43f0211b2a04eba36fed --- src/liblogger/liblogger.vc140.vcxproj.filters (.../liblogger.vc140.vcxproj.filters) (revision 545098ae76e9ce23598d37d2bee4020d6cb59f3c) +++ src/liblogger/liblogger.vc140.vcxproj.filters (.../liblogger.vc140.vcxproj.filters) (revision de48778626a2e3f6a09a43f0211b2a04eba36fed) @@ -53,6 +53,9 @@ Source Files + + Source Files + @@ -85,5 +88,8 @@ Source Files\internal + + Source Files + \ No newline at end of file