Index: src/ch/AsyncHttpFile.cpp =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/ch/AsyncHttpFile.cpp (.../AsyncHttpFile.cpp) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/ch/AsyncHttpFile.cpp (.../AsyncHttpFile.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -353,7 +353,7 @@ if(!pRequest || !pRequest->pHttpFile) return; - chcore::TLoggerPtr spLog = GetLogFactory()->CreateLogger(L"AsyncHttpFile"); + logger::TLoggerPtr spLog = logger::MakeLogger(GetLogFileData(), L"AsyncHttpFile"); CString strMsg; strMsg.Format(_T("[CAsyncHttpFile::InternetStatusCallback] hInternet: %p, dwContext: %Iu (operation: %lu), dwInternetStatus: %lu, lpvStatusInformation: %p, dwStatusInformationLength: %lu\n"), hInternet, (size_t)dwContext, pRequest->eOperationType, dwInternetStatus, lpvStatusInformation, dwStatusInformationLength); Index: src/ch/MainWnd.cpp =================================================================== diff -u -N -rb8b97b70743c49fcc2aee0db4cb7118db5e26dab -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision b8b97b70743c49fcc2aee0db4cb7118db5e26dab) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -81,7 +81,7 @@ // CMainWnd construction/destruction CMainWnd::CMainWnd() : m_spTaskMgrStats(new chcore::TTaskManagerStatsSnapshot), - m_spLog(GetLogFactory()->CreateLogger(L"MainWnd")) + m_spLog(logger::MakeLogger(GetLogFileData(), L"MainWnd")) { } @@ -246,15 +246,15 @@ IFeedbackHandlerFactoryPtr spFeedbackFactory(new CFeedbackHandlerFactory); chcore::TConfig& rConfig = GetConfig(); - TMultiLoggerConfigPtr spLoggerConfig = std::make_shared(); - spLoggerConfig->SetLogLevel(L"default", (boost::log::trivial::severity_level)GetPropValue(rConfig)); - spLoggerConfig->SetLogLevel(L"Filesystem", (boost::log::trivial::severity_level)GetPropValue(rConfig)); - spLoggerConfig->SetLogLevel(L"Filesystem-File", (boost::log::trivial::severity_level)GetPropValue(rConfig)); - spLoggerConfig->SetLogLevel(L"Task", (boost::log::trivial::severity_level)GetPropValue(rConfig)); - spLoggerConfig->SetLogLevel(L"ST-FastMove", (boost::log::trivial::severity_level)GetPropValue(rConfig)); - spLoggerConfig->SetLogLevel(L"ST-CopyMove", (boost::log::trivial::severity_level)GetPropValue(rConfig)); - spLoggerConfig->SetLogLevel(L"ST-Delete", (boost::log::trivial::severity_level)GetPropValue(rConfig)); - spLoggerConfig->SetLogLevel(L"ST-ScanDirs", (boost::log::trivial::severity_level)GetPropValue(rConfig)); + logger::TMultiLoggerConfigPtr spLoggerConfig = std::make_shared(); + spLoggerConfig->SetLogLevel(L"default", (logger::ESeverityLevel)GetPropValue(rConfig)); + spLoggerConfig->SetLogLevel(L"Filesystem", (logger::ESeverityLevel)GetPropValue(rConfig)); + spLoggerConfig->SetLogLevel(L"Filesystem-File", (logger::ESeverityLevel)GetPropValue(rConfig)); + spLoggerConfig->SetLogLevel(L"Task", (logger::ESeverityLevel)GetPropValue(rConfig)); + spLoggerConfig->SetLogLevel(L"ST-FastMove", (logger::ESeverityLevel)GetPropValue(rConfig)); + spLoggerConfig->SetLogLevel(L"ST-CopyMove", (logger::ESeverityLevel)GetPropValue(rConfig)); + spLoggerConfig->SetLogLevel(L"ST-Delete", (logger::ESeverityLevel)GetPropValue(rConfig)); + spLoggerConfig->SetLogLevel(L"ST-ScanDirs", (logger::ESeverityLevel)GetPropValue(rConfig)); try { Index: src/ch/MainWnd.h =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/ch/MainWnd.h (.../MainWnd.h) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/ch/MainWnd.h (.../MainWnd.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -87,7 +87,7 @@ DWORD m_dwLastTime = 0; UINT m_uiTaskbarRestart = 0; - chcore::TLoggerPtr m_spLog; + logger::TLoggerPtr m_spLog; }; #endif Index: src/ch/UpdaterDlg.cpp =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/ch/UpdaterDlg.cpp (.../UpdaterDlg.cpp) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/ch/UpdaterDlg.cpp (.../UpdaterDlg.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -30,7 +30,7 @@ ictranslate::CLanguageDialog(IDD_UPDATER_DIALOG, pParent), m_eLastState(CUpdateChecker::eResult_Undefined), m_bBackgroundMode(bBackgroundMode), - m_spLog(GetLogFactory()->CreateLogger(L"UpdaterDlg")) + m_spLog(logger::MakeLogger(GetLogFileData(), L"UpdaterDlg")) { RegisterStaticExControl(AfxGetInstanceHandle()); } Index: src/ch/UpdaterDlg.h =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/ch/UpdaterDlg.h (.../UpdaterDlg.h) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/ch/UpdaterDlg.h (.../UpdaterDlg.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -61,5 +61,5 @@ bool m_bBackgroundMode; ///< Do we operate in standard mode (false), or in background mode (true) - chcore::TLoggerPtr m_spLog; + logger::TLoggerPtr m_spLog; }; Index: src/ch/ch.cpp =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/ch/ch.cpp (.../ch.cpp) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/ch/ch.cpp (.../ch.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -44,6 +44,7 @@ #include "../libchcore/TWin32ErrorFormatter.h" #include "resource.h" #include "../liblogger/TLogger.h" +#include "../liblogger/TAsyncMultiLogger.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -307,17 +308,16 @@ } // ================================= Logging ======================================== - InitLoggers(strPath); + InitLoggers(); // logger config - chcore::TMultiLoggerConfigPtr spAppLoggerConfig = std::make_shared(); - spAppLoggerConfig->SetLogLevel(L"default", (boost::log::trivial::severity_level)GetPropValue(rCfg)); + logger::TMultiLoggerConfigPtr spAppLoggerConfig = std::make_shared(); + spAppLoggerConfig->SetLogLevel(L"default", (logger::ESeverityLevel)GetPropValue(rCfg)); // initialize the global log file if it is requested by configuration file CString strLogPath = strPath + _T("\\ch.log"); - m_spLogFactory.reset(new chcore::TLoggerFactory(chcore::PathFromString(strLogPath), spAppLoggerConfig)); - m_spLog = m_spLogFactory->CreateLogger(L"App"); + m_spLog = logger::MakeLogger(logger::TAsyncMultiLogger::GetInstance()->CreateLoggerData(strLogPath, spAppLoggerConfig), L"App"); LOG_INFO(m_spLog) << _T("============================ Initializing Copy Handler ============================"); LOG_INFO(m_spLog) << _T(""); @@ -496,18 +496,14 @@ return true; } -void CCopyHandlerApp::InitLoggers(const CString& strBasePath) +void CCopyHandlerApp::InitLoggers() { chcore::TConfig& rConfig = GetConfig(); int iMaxSize = GetPropValue(rConfig); int iRotateCount = GetPropValue(rConfig); - m_logInitializer.Init(chcore::PathFromString(strBasePath), iRotateCount, iMaxSize); - - chcore::TSmartPath pathTasks = chcore::PathFromString(strBasePath); - pathTasks += chcore::PathFromString(L"Tasks"); - m_chEngine.Init(pathTasks, iRotateCount, iMaxSize); + logger::TAsyncMultiLogger::GetInstance()->SetRotationInfo(iMaxSize, iRotateCount); } void CCopyHandlerApp::InitShellExtension() @@ -587,9 +583,9 @@ } } -chcore::TLoggerFactoryPtr CCopyHandlerApp::GetLogFactory() +logger::TLogFileDataPtr CCopyHandlerApp::GetLogFileData() const { - return m_spLogFactory; + return m_spLog->GetLogFileData(); } void CCopyHandlerApp::RegisterShellExtension() @@ -782,7 +778,7 @@ LOG_INFO(m_spLog) << _T("============================ Leaving Copy Handler ============================"); - m_logInitializer.Uninit(); + logger::TAsyncMultiLogger::GetInstance()->FinishLogging(); return __super::ExitInstance(); } Index: src/ch/ch.h =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/ch/ch.h (.../ch.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/ch/ch.h (.../ch.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -25,9 +25,7 @@ #include "TShellExtensionClient.h" #include "TCommandLineParser.h" #include "../liblogger/TLogger.h" -#include "../liblogger/TLoggerInitializer.h" #include "../libchcore/TCoreEngine.h" -#include "../liblogger/TLoggerFactory.h" class CCopyHandlerApp : public CWinApp, public CAppHelper { @@ -48,7 +46,7 @@ static ictranslate::CResourceManager& GetResManager(); static chcore::TConfig& GetConfig(); - chcore::TLoggerFactoryPtr GetLogFactory(); + logger::TLogFileDataPtr GetLogFileData() const; void RegisterShellExtension(); void UnregisterShellExtension(); @@ -70,25 +68,24 @@ TCommandLineParser m_cmdLineParser; chcore::TCoreEngine m_chEngine; - chcore::TLoggerInitializer m_logInitializer; - chcore::TLoggerFactoryPtr m_spLogFactory; - chcore::TLoggerPtr m_spLog; + logger::TLoggerPtr m_spLog; CWnd *m_pMainWindow; DECLARE_MESSAGE_MAP() + private: - void InitLoggers(const CString& strBasePath); + void InitLoggers(); }; inline CCopyHandlerApp& GetApp() { return GetApplication(); } -inline chcore::TLoggerFactoryPtr GetLogFactory() +inline logger::TLogFileDataPtr GetLogFileData() { - return GetApp().GetLogFactory(); + return GetApp().GetLogFileData(); } inline ictranslate::CResourceManager& GetResManager() Index: src/libchcore/TCoreEngine.cpp =================================================================== diff -u -N -rb8b97b70743c49fcc2aee0db4cb7118db5e26dab -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TCoreEngine.cpp (.../TCoreEngine.cpp) (revision b8b97b70743c49fcc2aee0db4cb7118db5e26dab) +++ src/libchcore/TCoreEngine.cpp (.../TCoreEngine.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -27,17 +27,5 @@ TCoreEngine::~TCoreEngine() { - Uninitialize(); } - - - void TCoreEngine::Init(const TSmartPath& pathLogs, unsigned int uiMaxRotatedFiles, unsigned long long ullMaxLogSize) - { - m_loggerInitializer.Init(pathLogs, uiMaxRotatedFiles, ullMaxLogSize); - } - - void TCoreEngine::Uninitialize() - { - m_loggerInitializer.Uninit(); - } } Index: src/libchcore/TCoreEngine.h =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TCoreEngine.h (.../TCoreEngine.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/libchcore/TCoreEngine.h (.../TCoreEngine.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -20,7 +20,6 @@ #define __TCOREENGINE_H__ #include "libchcore.h" -#include "../liblogger/TLoggerInitializer.h" namespace chcore { @@ -29,15 +28,6 @@ public: TCoreEngine(); ~TCoreEngine(); - - void Init(const TSmartPath& pathLogs, unsigned int uiMaxRotatedFiles, unsigned long long ullMaxLogSize); - void Uninitialize(); - - private: -#pragma warning(push) -#pragma warning(disable: 4251) - TLoggerInitializer m_loggerInitializer; -#pragma warning(pop) }; } Index: src/libchcore/TFilesystemFeedbackWrapper.cpp =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TFilesystemFeedbackWrapper.cpp (.../TFilesystemFeedbackWrapper.cpp) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TFilesystemFeedbackWrapper.cpp (.../TFilesystemFeedbackWrapper.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -25,10 +25,10 @@ namespace chcore { - TFilesystemFeedbackWrapper::TFilesystemFeedbackWrapper(const IFeedbackHandlerPtr& spFeedbackHandler, const IFilesystemPtr& spFilesystem, const TLoggerFactoryPtr& spLogFactory, TWorkerThreadController& rThreadController) : + TFilesystemFeedbackWrapper::TFilesystemFeedbackWrapper(const IFeedbackHandlerPtr& spFeedbackHandler, const IFilesystemPtr& spFilesystem, const logger::TLogFileDataPtr& spLogFileData, TWorkerThreadController& rThreadController) : m_spFeedbackHandler(spFeedbackHandler), m_spFilesystem(spFilesystem), - m_spLog(spLogFactory->CreateLogger(L"Filesystem")), + m_spLog(logger::MakeLogger(spLogFileData, L"Filesystem")), m_rThreadController(rThreadController) { if (!spFilesystem) Index: src/libchcore/TFilesystemFeedbackWrapper.h =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TFilesystemFeedbackWrapper.h (.../TFilesystemFeedbackWrapper.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/libchcore/TFilesystemFeedbackWrapper.h (.../TFilesystemFeedbackWrapper.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -22,7 +22,6 @@ #include "IFilesystem.h" #include "TSubTaskBase.h" #include "../liblogger/TLogger.h" -#include "../liblogger/TLoggerFactory.h" namespace chcore { @@ -31,7 +30,7 @@ class TFilesystemFeedbackWrapper { public: - TFilesystemFeedbackWrapper(const IFeedbackHandlerPtr& spFeedbackHandler, const IFilesystemPtr& spFilesystem, const TLoggerFactoryPtr& spLogFactory, TWorkerThreadController& rThreadController); + TFilesystemFeedbackWrapper(const IFeedbackHandlerPtr& spFeedbackHandler, const IFilesystemPtr& spFilesystem, const logger::TLogFileDataPtr& spLogFileData, TWorkerThreadController& rThreadController); TFilesystemFeedbackWrapper& operator=(const TFilesystemFeedbackWrapper&) = delete; TSubTaskBase::ESubOperationResult CreateDirectoryFB(const TSmartPath& pathDirectory); @@ -52,7 +51,7 @@ private: IFeedbackHandlerPtr m_spFeedbackHandler; IFilesystemPtr m_spFilesystem; - TLoggerPtr m_spLog; + logger::TLoggerPtr m_spLog; TWorkerThreadController& m_rThreadController; }; } Index: src/libchcore/TFilesystemFileFeedbackWrapper.cpp =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TFilesystemFileFeedbackWrapper.cpp (.../TFilesystemFileFeedbackWrapper.cpp) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TFilesystemFileFeedbackWrapper.cpp (.../TFilesystemFileFeedbackWrapper.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -26,9 +26,10 @@ namespace chcore { - TFilesystemFileFeedbackWrapper::TFilesystemFileFeedbackWrapper(const IFeedbackHandlerPtr& spFeedbackHandler, const TLoggerFactoryPtr& spLogFactory, TWorkerThreadController& rThreadController, const IFilesystemPtr& spFilesystem) : + TFilesystemFileFeedbackWrapper::TFilesystemFileFeedbackWrapper(const IFeedbackHandlerPtr& spFeedbackHandler, const logger::TLogFileDataPtr& spLogFileData, + TWorkerThreadController& rThreadController, const IFilesystemPtr& spFilesystem) : m_spFeedbackHandler(spFeedbackHandler), - m_spLog(spLogFactory->CreateLogger(L"Filesystem-File")), + m_spLog(std::make_unique(spLogFileData, L"Filesystem-File")), m_rThreadController(rThreadController), m_spFilesystem(spFilesystem) { Index: src/libchcore/TFilesystemFileFeedbackWrapper.h =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TFilesystemFileFeedbackWrapper.h (.../TFilesystemFileFeedbackWrapper.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/libchcore/TFilesystemFileFeedbackWrapper.h (.../TFilesystemFileFeedbackWrapper.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -24,7 +24,6 @@ #include "IFeedbackHandler.h" #include "IFilesystem.h" #include "../liblogger/TLogger.h" -#include "../liblogger/TLoggerFactory.h" namespace chcore { @@ -33,7 +32,7 @@ class TFilesystemFileFeedbackWrapper { public: - TFilesystemFileFeedbackWrapper(const IFeedbackHandlerPtr& spFeedbackHandler, const TLoggerFactoryPtr& spLogFactory, TWorkerThreadController& rThreadController, const IFilesystemPtr& spFilesystem); + TFilesystemFileFeedbackWrapper(const IFeedbackHandlerPtr& spFeedbackHandler, const logger::TLogFileDataPtr& spLogFileData, TWorkerThreadController& rThreadController, const IFilesystemPtr& spFilesystem); TFilesystemFileFeedbackWrapper& operator=(const TFilesystemFileFeedbackWrapper&) = delete; TSubTaskBase::ESubOperationResult OpenSourceFileFB(const IFilesystemFilePtr& fileSrc); @@ -58,7 +57,7 @@ private: IFeedbackHandlerPtr m_spFeedbackHandler; IFilesystemPtr m_spFilesystem; - TLoggerPtr m_spLog; + logger::TLoggerPtr m_spLog; TWorkerThreadController& m_rThreadController; }; } Index: src/libchcore/TSubTaskContext.cpp =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TSubTaskContext.cpp (.../TSubTaskContext.cpp) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TSubTaskContext.cpp (.../TSubTaskContext.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -30,22 +30,22 @@ { TSubTaskContext::TSubTaskContext(TConfig& rConfig, const TBasePathDataContainerPtr& spBasePaths, const TFileFiltersArray& rFilters, - TTaskConfigTracker& rCfgTracker, const TLoggerFactoryPtr& spLoggerFactory, + TTaskConfigTracker& rCfgTracker, const logger::TLogFileDataPtr& spLogFileData, TWorkerThreadController& rThreadController, const IFilesystemPtr& spFilesystem) : m_rConfig(rConfig), m_eOperationType(eOperation_None), m_spBasePaths(spBasePaths), m_pathDestination(), m_rCfgTracker(rCfgTracker), - m_spLoggerFactory(spLoggerFactory), + m_spLogFileData(spLogFileData), m_rThreadController(rThreadController), m_spFilesystem(spFilesystem), m_rFilters(rFilters) { if (!spFilesystem) throw TCoreException(eErr_InvalidArgument, L"spFilesystem", LOCATION); - if (!spLoggerFactory) - throw TCoreException(eErr_InvalidArgument, L"spLoggerFactory", LOCATION); + if (!spLogFileData) + throw TCoreException(eErr_InvalidArgument, L"spLogFileData", LOCATION); } TSubTaskContext::~TSubTaskContext() @@ -107,9 +107,9 @@ return m_rCfgTracker; } - TLoggerFactoryPtr TSubTaskContext::GetLogFactory() const + logger::TLogFileDataPtr TSubTaskContext::GetLogFileData() const { - return m_spLoggerFactory; + return m_spLogFileData; } TWorkerThreadController& TSubTaskContext::GetThreadController() Index: src/libchcore/TSubTaskContext.h =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TSubTaskContext.h (.../TSubTaskContext.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/libchcore/TSubTaskContext.h (.../TSubTaskContext.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -29,7 +29,7 @@ #include "TBasePathData.h" #include "TFileInfoArray.h" #include "IFilesystem.h" -#include "..\liblogger\TLoggerFactory.h" +#include "..\liblogger\TLogFileData.h" namespace chcore { @@ -46,7 +46,7 @@ public: TSubTaskContext(TConfig& rConfig, const TBasePathDataContainerPtr& spBasePaths, const TFileFiltersArray& rFilters, - TTaskConfigTracker& rCfgTracker, const TLoggerFactoryPtr& spLoggerFactory, + TTaskConfigTracker& rCfgTracker, const logger::TLogFileDataPtr& spLogFileData, TWorkerThreadController& rThreadController, const IFilesystemPtr& spFilesystem); ~TSubTaskContext(); @@ -68,7 +68,7 @@ TTaskConfigTracker& GetCfgTracker(); const TTaskConfigTracker& GetCfgTracker() const; - TLoggerFactoryPtr GetLogFactory() const; + logger::TLogFileDataPtr GetLogFileData() const; TWorkerThreadController& GetThreadController(); const TWorkerThreadController& GetThreadController() const; @@ -104,7 +104,7 @@ #pragma warning(push) #pragma warning(disable: 4251) IFilesystemPtr m_spFilesystem; - TLoggerFactoryPtr m_spLoggerFactory; + logger::TLogFileDataPtr m_spLogFileData; #pragma warning(pop) // thread control Index: src/libchcore/TSubTaskCopyMove.cpp =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -68,7 +68,7 @@ TSubTaskCopyMove::TSubTaskCopyMove(TSubTaskContext& rContext) : TSubTaskBase(rContext), m_tSubTaskStats(eSubOperation_Copying), - m_spLog(rContext.GetLogFactory()->CreateLogger(L"ST-CopyMove")) + m_spLog(std::make_unique(rContext.GetLogFileData(), L"ST-CopyMove")) { } @@ -109,7 +109,7 @@ IFilesystemPtr spFilesystem = GetContext().GetLocalFilesystem(); TBasePathDataContainerPtr spSrcPaths = GetContext().GetBasePaths(); - TFilesystemFeedbackWrapper tFilesystemFBWrapper(spFeedbackHandler, spFilesystem, GetContext().GetLogFactory(), rThreadController); + TFilesystemFeedbackWrapper tFilesystemFBWrapper(spFeedbackHandler, spFilesystem, GetContext().GetLogFileData(), rThreadController); // log LOG_INFO(m_spLog) << _T("Processing files/folders (ProcessFiles)"); @@ -336,7 +336,7 @@ const TConfig& rConfig = GetContext().GetConfig(); IFilesystemPtr spFilesystem = GetContext().GetLocalFilesystem(); - TFilesystemFileFeedbackWrapper tFileFBWrapper(spFeedbackHandler, GetContext().GetLogFactory(), rThreadController, spFilesystem); + TFilesystemFileFeedbackWrapper tFileFBWrapper(spFeedbackHandler, GetContext().GetLogFileData(), rThreadController, spFilesystem); TString strFormat; TSubTaskBase::ESubOperationResult eResult = TSubTaskBase::eSubResult_Continue; Index: src/libchcore/TSubTaskCopyMove.h =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TSubTaskCopyMove.h (.../TSubTaskCopyMove.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/libchcore/TSubTaskCopyMove.h (.../TSubTaskCopyMove.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -82,7 +82,7 @@ #pragma warning(push) #pragma warning(disable: 4251) TSubTaskStatsInfo m_tSubTaskStats; - TLoggerPtr m_spLog; + logger::TLoggerPtr m_spLog; #pragma warning(pop) }; } Index: src/libchcore/TSubTaskDelete.cpp =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -47,7 +47,7 @@ TSubTaskDelete::TSubTaskDelete(TSubTaskContext& rContext) : TSubTaskBase(rContext), m_tSubTaskStats(eSubOperation_Deleting), - m_spLog(rContext.GetLogFactory()->CreateLogger(L"ST-Delete")) + m_spLog(std::make_unique(rContext.GetLogFileData(), L"ST-Delete")) { } @@ -85,7 +85,7 @@ TWorkerThreadController& rThreadController = GetContext().GetThreadController(); IFilesystemPtr spFilesystem = GetContext().GetLocalFilesystem(); - TFilesystemFeedbackWrapper tFilesystemFBWrapper(spFeedbackHandler, spFilesystem, GetContext().GetLogFactory(), rThreadController); + TFilesystemFeedbackWrapper tFilesystemFBWrapper(spFeedbackHandler, spFilesystem, GetContext().GetLogFileData(), rThreadController); // log LOG_INFO(m_spLog) << _T("Deleting files (DeleteFiles)..."); Index: src/libchcore/TSubTaskDelete.h =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TSubTaskDelete.h (.../TSubTaskDelete.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/libchcore/TSubTaskDelete.h (.../TSubTaskDelete.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -54,7 +54,7 @@ #pragma warning(push) #pragma warning(disable: 4251) TSubTaskStatsInfo m_tSubTaskStats; - TLoggerPtr m_spLog; + logger::TLoggerPtr m_spLog; #pragma warning(pop) }; } Index: src/libchcore/TSubTaskFastMove.cpp =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -46,7 +46,7 @@ TSubTaskFastMove::TSubTaskFastMove(TSubTaskContext& rContext) : TSubTaskBase(rContext), m_tSubTaskStats(eSubOperation_FastMove), - m_spLog(rContext.GetLogFactory()->CreateLogger(L"ST-FastMove")) + m_spLog(std::make_unique(rContext.GetLogFileData(), L"ST-FastMove")) { } @@ -91,7 +91,7 @@ const TFileFiltersArray& rafFilters = GetContext().GetFilters(); IFilesystemPtr spFilesystem = GetContext().GetLocalFilesystem(); - TFilesystemFeedbackWrapper tFilesystemFBWrapper(spFeedbackHandler, spFilesystem, GetContext().GetLogFactory(), rThreadController); + TFilesystemFeedbackWrapper tFilesystemFBWrapper(spFeedbackHandler, spFilesystem, GetContext().GetLogFileData(), rThreadController); LOG_INFO(m_spLog) << _T("Performing initial fast-move operation..."); Index: src/libchcore/TSubTaskFastMove.h =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TSubTaskFastMove.h (.../TSubTaskFastMove.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/libchcore/TSubTaskFastMove.h (.../TSubTaskFastMove.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -57,7 +57,7 @@ #pragma warning(push) #pragma warning(disable: 4251) TSubTaskStatsInfo m_tSubTaskStats; - TLoggerPtr m_spLog; + logger::TLoggerPtr m_spLog; #pragma warning(pop) }; } Index: src/libchcore/TSubTaskScanDirectory.cpp =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -46,7 +46,7 @@ TSubTaskScanDirectories::TSubTaskScanDirectories(TSubTaskContext& rContext) : TSubTaskBase(rContext), m_tSubTaskStats(eSubOperation_Scanning), - m_spLog(rContext.GetLogFactory()->CreateLogger(L"ST-ScanDirs")) + m_spLog(std::make_unique(rContext.GetLogFileData(), L"ST-ScanDirs")) { } @@ -91,7 +91,7 @@ const TFileFiltersArray& rafFilters = GetContext().GetFilters(); IFilesystemPtr spFilesystem = GetContext().GetLocalFilesystem(); - TFilesystemFeedbackWrapper tFilesystemFBWrapper(spFeedbackHandler, spFilesystem, GetContext().GetLogFactory(), rThreadController); + TFilesystemFeedbackWrapper tFilesystemFBWrapper(spFeedbackHandler, spFilesystem, GetContext().GetLogFileData(), rThreadController); LOG_INFO(m_spLog) << _T("Searching for files..."); Index: src/libchcore/TSubTaskScanDirectory.h =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TSubTaskScanDirectory.h (.../TSubTaskScanDirectory.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/libchcore/TSubTaskScanDirectory.h (.../TSubTaskScanDirectory.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -62,7 +62,7 @@ #pragma warning(push) #pragma warning(disable: 4251) TSubTaskStatsInfo m_tSubTaskStats; - TLoggerPtr m_spLog; + logger::TLoggerPtr m_spLog; #pragma warning(pop) }; } Index: src/libchcore/TTask.cpp =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TTask.cpp (.../TTask.cpp) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TTask.cpp (.../TTask.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -41,21 +41,22 @@ #include #include "TLocalFilesystem.h" #include "TTaskConfigVerifier.h" +#include "../liblogger/TAsyncMultiLogger.h" namespace chcore { //////////////////////////////////////////////////////////////////////////// // TTask members TTask::TTask(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, - const TTaskDefinition& rTaskDefinition, const TSmartPath& rLogPath, const TMultiLoggerConfigPtr& spLoggerConfig) : - m_spLogFactory(new TLoggerFactory(rLogPath, spLoggerConfig)), + const TTaskDefinition& rTaskDefinition, const TSmartPath& rLogPath, const logger::TMultiLoggerConfigPtr& spLoggerConfig) : + m_spLog(std::make_unique(logger::TAsyncMultiLogger::GetInstance()->CreateLoggerData(rLogPath.ToString(), spLoggerConfig), L"Task")), m_spInternalFeedbackHandler(spFeedbackHandler), m_spSrcPaths(new TBasePathDataContainer), m_bForce(false), m_bContinue(false), m_tSubTaskContext(m_tConfiguration, m_spSrcPaths, m_afFilters, - m_cfgTracker, m_spLogFactory, m_workerThread, + m_cfgTracker, m_spLog->GetLogFileData(), m_workerThread, std::make_shared()), m_tSubTasksArray(m_tSubTaskContext), m_spSerializer(spSerializer) @@ -65,19 +66,18 @@ if(!spSerializer) throw TCoreException(eErr_InvalidArgument, L"spSerializer", LOCATION); - m_spLog = m_spLogFactory->CreateLogger(L"Task"); m_tBaseData.SetLogPath(rLogPath); SetTaskDefinition(rTaskDefinition); } - TTask::TTask(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, const TTaskBaseData& rBaseTaskData, const TMultiLoggerConfigPtr& spLoggerConfig) : - m_spLogFactory(new TLoggerFactory(rBaseTaskData.GetLogPath(), spLoggerConfig)), + TTask::TTask(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, const TTaskBaseData& rBaseTaskData, const logger::TMultiLoggerConfigPtr& spLoggerConfig) : + m_spLog(std::make_unique(logger::TAsyncMultiLogger::GetInstance()->CreateLoggerData(rBaseTaskData.GetLogPath().ToString(), spLoggerConfig), L"Task")), m_spInternalFeedbackHandler(spFeedbackHandler), m_spSrcPaths(new TBasePathDataContainer), m_bForce(false), m_bContinue(false), m_tSubTaskContext(m_tConfiguration, m_spSrcPaths, m_afFilters, - m_cfgTracker, m_spLogFactory, m_workerThread, + m_cfgTracker, m_spLog->GetLogFileData(), m_workerThread, std::make_shared()), m_tSubTasksArray(m_tSubTaskContext), m_spSerializer(spSerializer) @@ -86,8 +86,6 @@ throw TCoreException(eErr_InvalidArgument, L"spFeedbackHandler", LOCATION); if(!spSerializer) throw TCoreException(eErr_InvalidArgument, L"spSerializer", LOCATION); - - m_spLog = m_spLogFactory->CreateLogger(L"Task"); } TTask::~TTask() @@ -220,7 +218,7 @@ } } - TTaskPtr TTask::Load(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, const TMultiLoggerConfigPtr& spLoggerConfig) + TTaskPtr TTask::Load(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, const logger::TMultiLoggerConfigPtr& spLoggerConfig) { TTaskBaseData tBaseData; ISerializerContainerPtr spContainer = spSerializer->GetContainer(_T("task")); Index: src/libchcore/TTask.h =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TTask.h (.../TTask.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/libchcore/TTask.h (.../TTask.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -35,7 +35,6 @@ #include #include "IFilesystem.h" #include "..\liblogger\TLogger.h" -#include "..\liblogger\TLoggerFactory.h" namespace chcore { @@ -49,8 +48,8 @@ class LIBCHCORE_API TTask { private: - TTask(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, const TTaskBaseData& rBaseTaskData, const TMultiLoggerConfigPtr& spLoggerConfig); - TTask(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, const TTaskDefinition& rTaskDefinition, const TSmartPath& rLogPath, const TMultiLoggerConfigPtr& spLoggerConfig); + 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); public: ~TTask(); @@ -70,7 +69,7 @@ // thread void SetPriority(int nPriority); - static TTaskPtr Load(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, const TMultiLoggerConfigPtr& spLoggerConfig); + static TTaskPtr Load(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler, const logger::TMultiLoggerConfigPtr& spLoggerConfig); void Store(bool bForce); void BeginProcessing(); @@ -145,8 +144,7 @@ #pragma warning(push) #pragma warning(disable: 4251) - TLoggerFactoryPtr m_spLogFactory; - TLoggerPtr m_spLog; ///< Log file where task information will be stored + logger::TLoggerPtr m_spLog; ///< Log file where task information will be stored TBasePathDataContainerPtr m_spSrcPaths; #pragma warning(pop) Index: src/libchcore/TTaskConfigVerifier.cpp =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TTaskConfigVerifier.cpp (.../TTaskConfigVerifier.cpp) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/libchcore/TTaskConfigVerifier.cpp (.../TTaskConfigVerifier.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -24,15 +24,16 @@ namespace chcore { - void TTaskConfigVerifier::VerifyAndUpdate(TConfig& rConfig, const TLoggerPtr& spLog) + void TTaskConfigVerifier::VerifyAndUpdate(TConfig& rConfig, const logger::TLoggerPtr& spLog) { TString strFirstFormat = GetTaskPropValue(rConfig); if(strFirstFormat.Find(L"%name") == TString::npos || strFirstFormat.Find(L"%ext") == TString::npos) { TString strDefaultFormat = TaskPropData::GetDefaultValue(); if(spLog) { - LOG_WARNING(spLog) << boost::str(boost::wformat(L"First alternate filename format string (%1%) does not contain %%name placeholder. Switching to default (%2%).") + LOG_WARNING(spLog) << + boost::str(boost::wformat(L"First alternate filename format string (%1%) does not contain %%name placeholder. Switching to default (%2%).") % strFirstFormat.c_str() % strDefaultFormat.c_str()).c_str(); } Index: src/libchcore/TTaskConfigVerifier.h =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TTaskConfigVerifier.h (.../TTaskConfigVerifier.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/libchcore/TTaskConfigVerifier.h (.../TTaskConfigVerifier.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -28,7 +28,7 @@ class TTaskConfigVerifier { public: - static void VerifyAndUpdate(TConfig& rConfig, const TLoggerPtr& spLog); + static void VerifyAndUpdate(TConfig& rConfig, const logger::TLoggerPtr& spLog); }; } Index: src/libchcore/TTaskManager.cpp =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TTaskManager.cpp (.../TTaskManager.cpp) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TTaskManager.cpp (.../TTaskManager.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -36,7 +36,7 @@ TTaskManager::TTaskManager(const ISerializerFactoryPtr& spSerializerFactory, const IFeedbackHandlerFactoryPtr& spFeedbackHandlerFactory, const TSmartPath& pathLogDir, - const TMultiLoggerConfigPtr& spMultiLoggerConfig, + const logger::TMultiLoggerConfigPtr& spMultiLoggerConfig, bool bForceRecreateSerializer) : m_spSerializerFactory(spSerializerFactory), m_spFeedbackFactory(spFeedbackHandlerFactory), Index: src/libchcore/TTaskManager.h =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/libchcore/TTaskManager.h (.../TTaskManager.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/libchcore/TTaskManager.h (.../TTaskManager.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -43,7 +43,7 @@ TTaskManager(const ISerializerFactoryPtr& spSerializerFactory, const IFeedbackHandlerFactoryPtr& spFeedbackHandlerFactory, const TSmartPath& pathLogDir, - const TMultiLoggerConfigPtr& spMultiLoggerConfig, + const logger::TMultiLoggerConfigPtr& spMultiLoggerConfig, bool bForceRecreateSerializer = false); ~TTaskManager(); @@ -103,7 +103,7 @@ IFeedbackHandlerFactoryPtr m_spFeedbackFactory; ISerializerPtr m_spSerializer; ISerializerFactoryPtr m_spSerializerFactory; - TMultiLoggerConfigPtr m_spMultiLoggerConfig; + logger::TMultiLoggerConfigPtr m_spMultiLoggerConfig; #pragma warning(pop) }; Index: src/liblogger/SeverityLevels.h =================================================================== diff -u -N --- src/liblogger/SeverityLevels.h (revision 0) +++ src/liblogger/SeverityLevels.h (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -0,0 +1,56 @@ +// ============================================================================ +// 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 __SEVERITYLEVELS_H__ +#define __SEVERITYLEVELS_H__ + +namespace logger +{ + enum ESeverityLevel + { + trace, + debug, + info, + warning, + error, + critical + }; + + inline std::wstring SeverityLevelToString(ESeverityLevel eLevel) + { + switch(eLevel) + { + case trace: + return L"trace"; + case debug: + return L"debug"; + case info: + return L"info"; + case warning: + return L"warning"; + case error: + return L"error"; + case critical: + return L"critical"; + default: + return L"unknown"; + } + } +} + +#endif Index: src/liblogger/TAsyncMultiLogger.cpp =================================================================== diff -u -N --- src/liblogger/TAsyncMultiLogger.cpp (revision 0) +++ src/liblogger/TAsyncMultiLogger.cpp (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -0,0 +1,116 @@ +// ============================================================================ +// 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 "TAsyncMultiLogger.h" +#include +#include + +namespace logger +{ + TAsyncMultiLoggerPtr TAsyncMultiLogger::GetInstance() + { + static TAsyncMultiLoggerPtr Logger(new TAsyncMultiLogger); + return Logger; + } + + TAsyncMultiLogger::TAsyncMultiLogger() : + m_spStopEvent(CreateEvent(nullptr, TRUE, FALSE, nullptr), CloseHandle), + m_spGlobalRotationInfo(std::make_shared()) + { + } + + void TAsyncMultiLogger::FinishLogging() + { + std::unique_ptr spThread; + + { + boost::unique_lock lock(m_mutex); + SetEvent(m_spStopEvent.get()); + std::swap(m_spThread, spThread); + } + + if(spThread) + { + if(spThread->joinable()) + spThread->join(); + } + + { + boost::unique_lock lock(m_mutex); + m_setLoggerData.clear(); + } + } + + TLogFileDataPtr TAsyncMultiLogger::CreateLoggerData(PCTSTR pszLogPath, const TMultiLoggerConfigPtr& spLoggerConfig) + { + TLogFileDataPtr spLogFileData = std::make_shared(pszLogPath, spLoggerConfig, m_spGlobalRotationInfo); + + boost::unique_lock lock(m_mutex); + m_setLoggerData.insert(spLogFileData); + + if(!m_spThread) + m_spThread.reset(new std::thread(&TAsyncMultiLogger::LoggingThread, this)); + + return spLogFileData; + } + + TLoggerRotationInfoPtr TAsyncMultiLogger::GetRotationInfo() const + { + return m_spGlobalRotationInfo; + } + + void TAsyncMultiLogger::SetRotationInfo(unsigned long long ullMaxLogSize, unsigned long ulMaxRotatedCount) + { + m_spGlobalRotationInfo->SetRotationInfo(ullMaxLogSize, ulMaxRotatedCount); + } + + void TAsyncMultiLogger::LoggingThread() + { + std::vector vHandles; + + do + { + { + boost::unique_lock lock(m_mutex); + vHandles.clear(); + vHandles.push_back(m_spStopEvent.get()); + + std::transform(m_setLoggerData.begin(), m_setLoggerData.end(), std::back_inserter(vHandles), [](const TLogFileDataPtr& rData) { return rData->GetEntriesEvent().get(); }); + } + + DWORD dwWaitResult = WaitForMultipleObjectsEx(boost::numeric_cast(vHandles.size()), &vHandles[ 0 ], FALSE, 500, FALSE); + if(dwWaitResult == WAIT_OBJECT_0) + return; + + std::vector vLogs; + { + boost::shared_lock lock(m_mutex); + vLogs.insert(vLogs.begin(), m_setLoggerData.begin(), m_setLoggerData.end()); + } + + for (const TLogFileDataPtr& spLogData : vLogs) + { + spLogData->StoreLogEntries(); + spLogData->CloseUnusedFile(); + } + } + while(true); + } + +} Index: src/liblogger/TAsyncMultiLogger.h =================================================================== diff -u -N --- src/liblogger/TAsyncMultiLogger.h (revision 0) +++ src/liblogger/TAsyncMultiLogger.h (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -0,0 +1,61 @@ +// ============================================================================ +// 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 __TASYNCMULTILOGGER_H__ +#define __TASYNCMULTILOGGER_H__ + +#include "TLogFileData.h" +#include +#include +#include "TLoggerRotationInfo.h" + +namespace logger +{ + class TAsyncMultiLogger; + + using TAsyncMultiLoggerPtr = std::shared_ptr; + + class TAsyncMultiLogger + { + public: + static TAsyncMultiLoggerPtr GetInstance(); + + public: + TAsyncMultiLogger(); + + void FinishLogging(); + TLogFileDataPtr CreateLoggerData(PCTSTR pszLogPath, const TMultiLoggerConfigPtr& spLoggerConfig); + + TLoggerRotationInfoPtr GetRotationInfo() const; + void SetRotationInfo(unsigned long long ullMaxLogSize, unsigned long ulMaxRotatedCount); + + private: + void LoggingThread(); + + private: + std::unordered_set m_setLoggerData; + boost::shared_mutex m_mutex; + + std::shared_ptr m_spStopEvent; + std::unique_ptr m_spThread; + + TLoggerRotationInfoPtr m_spGlobalRotationInfo; + }; +} + +#endif Index: src/liblogger/TDateTimeFormatter.cpp =================================================================== diff -u -N --- src/liblogger/TDateTimeFormatter.cpp (revision 0) +++ src/liblogger/TDateTimeFormatter.cpp (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -0,0 +1,38 @@ +// ============================================================================ +// 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 "TDateTimeFormatter.h" +#include +#include + +namespace logger +{ + std::wstring TDateTimeFormatter::GetCurrentTime() + { + boost::posix_time::ptime currentTime = boost::posix_time::microsec_clock::local_time(); + std::wstringstream wss; + boost::posix_time::time_facet* facet = new boost::posix_time::time_facet(); + facet->format("%Y-%m-%d %H:%M:%S.%f"); + wss.imbue(std::locale(std::locale::classic(), facet)); + wss << currentTime; + + return wss.str(); + } + +} Index: src/liblogger/TDateTimeFormatter.h =================================================================== diff -u -N --- src/liblogger/TDateTimeFormatter.h (revision 0) +++ src/liblogger/TDateTimeFormatter.h (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -0,0 +1,33 @@ +// ============================================================================ +// 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 __TDATETIMEFORMATTER_H__ +#define __TDATETIMEFORMATTER_H__ + +#include + +namespace logger +{ + class TDateTimeFormatter + { + public: + static std::wstring GetCurrentTime(); + }; +} + +#endif Index: src/liblogger/TLogFile.cpp =================================================================== diff -u -N --- src/liblogger/TLogFile.cpp (revision 0) +++ src/liblogger/TLogFile.cpp (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -0,0 +1,174 @@ +// ============================================================================ +// 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 "TLogFile.h" +#include +#include +#include + +namespace logger +{ + TLogFile::TLogFile(PCTSTR pszPath, const TLoggerRotationInfoPtr& spRotationInfo) : + m_strLogPath(pszPath), + m_spFileHandle(nullptr, CloseHandle), + m_spRotationInfo(spRotationInfo) + { + if(!pszPath) + throw std::invalid_argument("pszPath"); + if(!spRotationInfo) + throw std::invalid_argument("spRotationInfo"); + + ScanForRotatedLogs(); + } + + void TLogFile::Write(std::list& rListEntries) + { + for (const std::wstring& rEntry : rListEntries) + { + size_t stEntryLen = rEntry.length() * sizeof(wchar_t); + if (NeedRotation(stEntryLen)) + RotateFile(); + + DWORD dwWritten = 0; + if (!WriteFile(GetFileHandle(), rEntry.c_str(), boost::numeric_cast(stEntryLen), &dwWritten, nullptr)) + { + rListEntries.clear(); // get rid of the entries to not pile up indefinitely + throw std::runtime_error("Cannot write to file"); + } + } + + m_timeLastWriteTime = time(nullptr); + rListEntries.clear(); + } + + void TLogFile::CloseIfUnused() + { + if (time(nullptr) - m_timeLastWriteTime > MaxHandleCacheTime) + CloseLogFile(); + } + + void TLogFile::CloseLogFile() + { + m_spFileHandle.reset(); + } + + HANDLE TLogFile::GetFileHandle() + { + if (m_spFileHandle != nullptr) + return m_spFileHandle.get(); + + HANDLE hFile = CreateFile(m_strLogPath.c_str(), GENERIC_WRITE, FILE_SHARE_READ, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); + if (hFile == INVALID_HANDLE_VALUE) + throw std::runtime_error("Cannot open log file"); + + m_spFileHandle.reset(hFile, CloseHandle); + + LARGE_INTEGER liSeek = { 0 }; + + BOOL bRes = SetFilePointerEx(hFile, liSeek, nullptr, SEEK_END); + if (!bRes) + throw std::runtime_error("Cannot seek to the end of log file"); + + return m_spFileHandle.get(); + } + + unsigned long long TLogFile::GetCurrentLogSize() + { + LARGE_INTEGER liSize = { 0 }; + if (!GetFileSizeEx(GetFileHandle(), &liSize)) + throw std::runtime_error("Cannot determine current log size"); + + return liSize.QuadPart; + } + + void TLogFile::RotateFile() + { + m_spFileHandle.reset(); + + std::wstring pathNew = m_strLogPath; + if (boost::iends_with(pathNew, L".log")) + pathNew.erase(pathNew.end() - 4, pathNew.end()); + + boost::posix_time::ptime timeNow = boost::posix_time::second_clock::local_time(); + boost::posix_time::time_facet* facet = new boost::posix_time::time_facet(); + facet->format("%Y%m%d%H%M%S"); + std::wstringstream stream; + stream.imbue(std::locale(std::locale::classic(), facet)); + stream << time; + pathNew += L"."; + pathNew += stream.str().c_str(); + pathNew += L".log"; + + if (!MoveFile(m_strLogPath.c_str(), pathNew.c_str())) + throw std::runtime_error("Cannot rotate file"); + + m_vRotatedFiles.push_back(std::move(pathNew)); + RemoveObsoleteRotatedLogs(); + } + + void TLogFile::RemoveObsoleteRotatedLogs() + { + while (m_vRotatedFiles.size() > m_spRotationInfo->GetMaxRotatedCount()) + { + auto iterRotatedFile = m_vRotatedFiles.begin(); + if (!DeleteFile(iterRotatedFile->c_str())) + break; + + m_vRotatedFiles.erase(iterRotatedFile); + } + } + + void TLogFile::ScanForRotatedLogs() + { + std::wstring strSearchMask = m_strLogPath; + std::wstring strDir; + + size_t stDirPos = strSearchMask.find_last_of(L"\\/"); + if (stDirPos != std::wstring::npos) + strDir = strSearchMask.substr(0, stDirPos + 1); + + if (boost::iends_with(strSearchMask, L".log")) + strSearchMask.erase(strSearchMask.end() - 4, strSearchMask.end()); + strSearchMask += L".*.log"; + + std::vector vPaths; + WIN32_FIND_DATA wfd = { 0 }; + + HANDLE hFind = FindFirstFile(strSearchMask.c_str(), &wfd); + BOOL bFound = (hFind != INVALID_HANDLE_VALUE); + while (bFound) + { + std::wstring strLogFullPath = strDir + wfd.cFileName; + vPaths.push_back(strLogFullPath); + + bFound = FindNextFile(hFind, &wfd); + } + + std::sort(vPaths.begin(), vPaths.end(), [](const std::wstring& path1, const std::wstring& path2) { return boost::ilexicographical_compare(path2, path1); }); + std::swap(m_vRotatedFiles, vPaths); + } + + bool TLogFile::NeedRotation(size_t stDataSize) + { + unsigned long long ullCurrentSize = GetCurrentLogSize(); + unsigned long long ullMaxLogSize = m_spRotationInfo->GetMaxLogSize(); + + return ullCurrentSize + stDataSize > ullMaxLogSize; + } +} Index: src/liblogger/TLogFile.h =================================================================== diff -u -N --- src/liblogger/TLogFile.h (revision 0) +++ src/liblogger/TLogFile.h (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -0,0 +1,62 @@ +// ============================================================================ +// 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 __TLOGFILE_H__ +#define __TLOGFILE_H__ + +#include +#include "TLoggerRotationInfo.h" +#include +#include + +namespace logger +{ + // not exportable + class TLogFile + { + public: + static const time_t MaxHandleCacheTime = 60; + + public: + TLogFile(PCTSTR pszPath, const TLoggerRotationInfoPtr& spRotationInfo); + + void Write(std::list& pszData); + void CloseIfUnused(); + void CloseLogFile(); + + private: + HANDLE GetFileHandle(); + unsigned long long GetCurrentLogSize(); + void RotateFile(); + void RemoveObsoleteRotatedLogs(); + void ScanForRotatedLogs(); + bool NeedRotation(size_t stDataSize); + + private: + std::wstring m_strLogPath; + + time_t m_timeLastWriteTime = 0; + std::shared_ptr m_spFileHandle; + + // rotation + TLoggerRotationInfoPtr m_spRotationInfo; + std::vector m_vRotatedFiles; + }; +} + +#endif Index: src/liblogger/TLogFileData.cpp =================================================================== diff -u -N --- src/liblogger/TLogFileData.cpp (revision 0) +++ src/liblogger/TLogFileData.cpp (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -0,0 +1,59 @@ +// ============================================================================ +// 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 "TLogFileData.h" + +namespace logger +{ + TLogFileData::TLogFileData(std::wstring pathLog, const TMultiLoggerConfigPtr& spLoggerConfig, const TLoggerRotationInfoPtr& spRotationInfo) : + m_spHasEntriesEvent(CreateEvent(nullptr, TRUE, FALSE, nullptr), CloseHandle), + m_spLoggerConfig(spLoggerConfig), + m_logFile(pathLog.c_str(), spRotationInfo) + { + if(m_spHasEntriesEvent.get() == INVALID_HANDLE_VALUE) + throw std::runtime_error("Cannot create file data event"); + } + + TMultiLoggerConfigPtr TLogFileData::GetLoggerConfig() const + { + return m_spLoggerConfig; + } + + std::shared_ptr TLogFileData::GetEntriesEvent() const + { + return m_spHasEntriesEvent; + } + + void TLogFileData::PushLogEntry(std::wstring strLine) + { + boost::unique_lock lock(m_mutex); + m_listEntries.emplace_back(strLine); + SetEvent(m_spHasEntriesEvent.get()); + } + + void TLogFileData::StoreLogEntries() + { + m_logFile.Write(m_listEntries); + } + + void TLogFileData::CloseUnusedFile() + { + m_logFile.CloseIfUnused(); + } +} Index: src/liblogger/TLogFileData.h =================================================================== diff -u -N --- src/liblogger/TLogFileData.h (revision 0) +++ src/liblogger/TLogFileData.h (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -0,0 +1,58 @@ +// ============================================================================ +// 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 __TLOGFILEDATA_H__ +#define __TLOGFILEDATA_H__ + +#include +#include +#include +#include "TLogFile.h" +#include "TMultiLoggerConfig.h" + +namespace logger +{ + class TLogFileData + { + public: + TLogFileData(std::wstring pathLog, const TMultiLoggerConfigPtr& spLoggerConfig, const TLoggerRotationInfoPtr& spRotationInfo); + + TMultiLoggerConfigPtr GetLoggerConfig() const; + + //std::wstring GetLogPath() const; + std::shared_ptr GetEntriesEvent() const; + + void PushLogEntry(std::wstring strLine); + + void StoreLogEntries(); + void CloseUnusedFile(); + + private: + std::list m_listEntries; + boost::shared_mutex m_mutex; + std::shared_ptr m_spHasEntriesEvent; + + TMultiLoggerConfigPtr m_spLoggerConfig; + + TLogFile m_logFile; + }; + + using TLogFileDataPtr = std::shared_ptr; +} + +#endif Index: src/liblogger/TLogRecord.h =================================================================== diff -u -N --- src/liblogger/TLogRecord.h (revision 0) +++ src/liblogger/TLogRecord.h (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -0,0 +1,70 @@ +// ============================================================================ +// 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 __TLOGRECORD_H__ +#define __TLOGRECORD_H__ + +#include +#include "TLogFileData.h" +#include +#include "TDateTimeFormatter.h" + +namespace logger +{ + // do not export! + class TLogRecord : public std::wstringstream + { + public: + TLogRecord(const TLogRecord&) = delete; + TLogRecord(TLogRecord&& rSrc) : + std::wstringstream(std::move(rSrc)), + m_spFileData(std::move(rSrc.m_spFileData)) + { + } + + TLogRecord& operator=(const TLogRecord&) = delete; + + TLogRecord(const TLogFileDataPtr& spFileData, ESeverityLevel eLevel) : + m_spFileData(spFileData) + { + *this << TDateTimeFormatter::GetCurrentTime() << L" " << SeverityLevelToString(eLevel) << " "; + } + + ~TLogRecord() + { + *this << L"\r\n"; + m_spFileData->PushLogEntry(str()); + } + + bool IsEnabled() const + { + return m_bEnabled; + } + + void Disable() + { + m_bEnabled = false; + } + + private: + TLogFileDataPtr m_spFileData; + bool m_bEnabled = true; + }; +} + +#endif Index: src/liblogger/TLogRotator.cpp =================================================================== diff -u -N --- src/liblogger/TLogRotator.cpp (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/liblogger/TLogRotator.cpp (revision 0) @@ -1,97 +0,0 @@ -// ============================================================================ -// 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 "TLogRotator.h" -#include -#include -#include "..\libchcore\TString.h" -#include "TLogSinkCollection.h" -#include "..\libchcore\TFileException.h" -#include - -namespace chcore -{ - TLogRotator::TLogRotator(unsigned int uiMaxRotatedFiles, unsigned long long ullMaxLogSize) : - m_uiMaxRotatedFiles(uiMaxRotatedFiles), - m_ullMaxLogSize(ullMaxLogSize) - { - } - - void TLogRotator::SetLimits(unsigned int uiMaxRotatedFiles, unsigned long long ullMaxLogSize) - { - m_uiMaxRotatedFiles = uiMaxRotatedFiles; - m_ullMaxLogSize = ullMaxLogSize; - } - - void TLogRotator::RotateFile(const TSmartPath& pathLog, TLogSink& sinkData, size_t stRequiredSpace) - { - unsigned long long ullCurrentLogSize = sinkData.GetCurrentLogSize(); - unsigned long long ullNewSize = ullCurrentLogSize + stRequiredSpace; - if (ullCurrentLogSize == 0 || ullNewSize < m_ullMaxLogSize) - return; - - sinkData.CloseLogFile(); - - TString pathNew = pathLog.ToWString(); - if (pathNew.EndsWithNoCase(L".log")) - pathNew.LeftSelf(pathNew.GetLength() - 4); - - boost::posix_time::ptime timeNow = boost::posix_time::second_clock::local_time(); - boost::posix_time::time_facet* facet = new boost::posix_time::time_facet(); - facet->format("%Y%m%d%H%M%S"); - std::wstringstream stream; - stream.imbue(std::locale(std::locale::classic(), facet)); - stream << time; - pathNew.Append(L"."); - pathNew.Append(stream.str().c_str()); - pathNew.Append(L".log"); - - if (!MoveFile(pathLog.ToString(), pathNew.c_str())) - throw TFileException(eErr_CannotFastMove, GetLastError(), pathLog, L"Cannot rotate file", LOCATION); - - sinkData.AddRotatedFile(PathFromWString(pathNew)); - sinkData.RemoveObsoleteRotatedLogs(m_uiMaxRotatedFiles); - } - - void TLogRotator::ScanForLogs(const TSmartPath& pathDir, TLogSinkCollection& rCollection) - { - TSmartPath pathSearch = pathDir; - pathSearch += PathFromString(L"*.log"); - - std::vector vPaths; - WIN32_FIND_DATA wfd = { 0 }; - - HANDLE hFind = FindFirstFile(pathSearch.ToString(), &wfd); - BOOL bFound = (hFind != INVALID_HANDLE_VALUE); - while (bFound) - { - TSmartPath pathFound = pathDir + PathFromString(wfd.cFileName); - vPaths.push_back(pathFound); - - bFound = FindNextFile(hFind, &wfd); - } - - std::sort(vPaths.begin(), vPaths.end(), [](const TSmartPath& path1, const TSmartPath& path2) { return path2 > path1; }); - - for (const TSmartPath& rPath : vPaths) - { - rCollection.AddPath(rPath); - } - } -} Index: src/liblogger/TLogSink.cpp =================================================================== diff -u -N --- src/liblogger/TLogSink.cpp (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/liblogger/TLogSink.cpp (revision 0) @@ -1,84 +0,0 @@ -// ============================================================================ -// 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 "TLogSink.h" -#include "..\libchcore\TFileException.h" - -namespace chcore -{ - TLogSink::TLogSink(const chcore::TSmartPath& pathLog) - : m_pathLog(pathLog) - { - } - - HANDLE TLogSink::GetFileHandle() - { - if (m_handleFile != INVALID_HANDLE_VALUE) - return m_handleFile; - - m_handleFile = CreateFile(m_pathLog.ToString(), GENERIC_WRITE, FILE_SHARE_READ, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); - if (m_handleFile == INVALID_HANDLE_VALUE) - throw TFileException(eErr_CannotOpenFile, GetLastError(), m_pathLog, L"Cannot open log file", LOCATION); - - LARGE_INTEGER liSeek = { 0 }; - - BOOL bRes = SetFilePointerEx(m_handleFile, liSeek, nullptr, SEEK_END); - if (!bRes) - throw TFileException(eErr_CannotOpenFile, GetLastError(), m_pathLog, L"Cannot seek to the end of log file", LOCATION); - - return m_handleFile; - } - - unsigned long long TLogSink::GetCurrentLogSize() - { - LARGE_INTEGER liSize = { 0 }; - if (!GetFileSizeEx(GetFileHandle(), &liSize)) - throw new TFileException(eErr_CannotGetFileInfo, GetLastError(), m_pathLog, L"Cannot determine current log size", LOCATION); - - return liSize.QuadPart; - } - - void TLogSink::AddRotatedFile(const TSmartPath& rPath) - { - m_setRotatedFiles.insert(rPath); - } - - void TLogSink::RemoveObsoleteRotatedLogs(unsigned int uiMaxRotatedFiles) - { - while (m_setRotatedFiles.size() > uiMaxRotatedFiles) - { - auto iterRotatedFile = m_setRotatedFiles.begin(); - if (!DeleteFile(iterRotatedFile->ToString())) - break; - - m_setRotatedFiles.erase(iterRotatedFile); - } - } - - void chcore::TLogSink::CloseLogFile() - { - m_handleFile.Close(); - } - - void chcore::TLogSink::CloseIfTimedOut(unsigned long long ullCurrentTimestamp, unsigned long long ullMaxHandleCacheTime) - { - if (ullCurrentTimestamp - m_ullLastUsageTimestamp > ullMaxHandleCacheTime) - CloseLogFile(); - } -} Index: src/liblogger/TLogSinkCollection.cpp =================================================================== diff -u -N --- src/liblogger/TLogSinkCollection.cpp (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/liblogger/TLogSinkCollection.cpp (revision 0) @@ -1,81 +0,0 @@ -// ============================================================================ -// 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 "TLogSinkCollection.h" -#include "..\libchcore\TStringArray.h" -#include - -namespace chcore -{ - TLogSinkCollection::TLogSinkCollection() - { - - } - - void TLogSinkCollection::AddPath(const TSmartPath& rPath) - { - TStringArray arrComponents; - TSmartPath pathToFileWithoutExtension = rPath.GetFileTitle(); - pathToFileWithoutExtension.ToWString().Split(L".", arrComponents); - - switch (arrComponents.GetCount()) - { - case 0: - break; - case 1: - { - GetSinkData(rPath); - break; - } - default: - { - TSmartPath pathBase = rPath.GetFileDir() + pathToFileWithoutExtension.GetFileTitle(); - TLogSink& rSinkData = GetSinkData(pathBase); - - std::wstring strRotateInfo = arrComponents.GetAt(arrComponents.GetCount() - 1).c_str(); - if (std::all_of(strRotateInfo.begin(), strRotateInfo.end(), isdigit)) - { - rSinkData.AddRotatedFile(rPath); - } - } - } - } - - TLogSink& TLogSinkCollection::GetSinkData(const TSmartPath& path) - { - auto iterFind = m_mapLogs.find(path); - if (iterFind == m_mapLogs.end()) - iterFind = m_mapLogs.insert(std::make_pair(path, TLogSink(path))).first; - - return iterFind->second; - } - - void TLogSinkCollection::Clear() - { - m_mapLogs.clear(); - } - - void TLogSinkCollection::CloseExpiredFiles(unsigned long long ullCurrentTimestamp, unsigned long long ullMaxHandleCacheTime) - { - for (auto& pairSink : m_mapLogs) - { - pairSink.second.CloseIfTimedOut(ullCurrentTimestamp, ullMaxHandleCacheTime); - } - } -} Index: src/liblogger/TLogger.cpp =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/liblogger/TLogger.cpp (.../TLogger.cpp) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/liblogger/TLogger.cpp (.../TLogger.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -1,44 +1,48 @@ -// ============================================================================ -// 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 "TLogger.h" -#include -#include "../libchcore/TCoreException.h" - -namespace keywords = boost::log::keywords; - -namespace chcore -{ - TLogger::TLogger(const TLoggerLevelConfigPtr& spLoggerConfig, const TLoggerLocationConfigPtr& spLogLocation, PCTSTR pszChannel) : - Logger(keywords::channel = pszChannel), - m_spLoggerConfig(spLoggerConfig) - { - if (!spLoggerConfig) - throw TCoreException(eErr_InvalidArgument, L"spLoggerConfig", LOCATION); - if (!spLogLocation) - throw TCoreException(eErr_InvalidArgument, L"spLogLocation", LOCATION); - - m_iterLogPath = add_attribute("LogPath", boost::log::attributes::constant(spLogLocation)).first; - } - - severity_level TLogger::GetMinSeverity() const - { - return m_spLoggerConfig->GetMinSeverityLevel(); - } -} +// ============================================================================ +// 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 "TLogger.h" +#include "TMultiLoggerConfig.h" + +namespace logger +{ + TLogger::TLogger(const TLogFileDataPtr& spFileData, PCTSTR pszChannel) : + m_spFileData(spFileData), + m_spLoggerConfig(spFileData->GetLoggerConfig()->GetLoggerConfig(pszChannel)), + m_strChannel(pszChannel) + { + if (!spFileData) + throw std::invalid_argument("spFileData"); + } + + TLogFileDataPtr TLogger::GetLogFileData() const + { + return m_spFileData; + } + + ESeverityLevel TLogger::GetMinSeverity() const + { + return m_spLoggerConfig->GetMinSeverityLevel(); + } + + TLogRecord TLogger::OpenLogRecord(ESeverityLevel eLevel) const + { + return TLogRecord(m_spFileData, eLevel); + } +} Index: src/liblogger/TLogger.h =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/liblogger/TLogger.h (.../TLogger.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/liblogger/TLogger.h (.../TLogger.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -1,58 +1,66 @@ -// ============================================================================ -// 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 __TLOGGER_H__ -#define __TLOGGER_H__ - -#include -#include -#include "TLoggerLevelConfig.h" -#include "TLoggerLocationConfig.h" -#include - -using boost::log::trivial::severity_level; -using Logger = boost::log::sources::wseverity_channel_logger_mt; - -namespace chcore -{ - class TLogger : public Logger - { - private: - TLogger(const TLoggerLevelConfigPtr& spLoggerConfig, const TLoggerLocationConfigPtr& spLogLocation, PCTSTR pszChannel); - - public: - severity_level GetMinSeverity() const; - - private: - boost::log::attribute_set::iterator m_iterLogPath; - TLoggerLevelConfigPtr m_spLoggerConfig; - - friend class TLoggerFactory; - }; - - using TLoggerPtr = std::unique_ptr; -} - -#define LOG_TRACE(logger) if(boost::log::trivial::trace >= (logger)->GetMinSeverity()) BOOST_LOG_SEV((*logger), boost::log::trivial::trace) -#define LOG_DEBUG(logger) if(boost::log::trivial::debug >= (logger)->GetMinSeverity()) BOOST_LOG_SEV((*logger), boost::log::trivial::debug) -#define LOG_INFO(logger) if(boost::log::trivial::info >= (logger)->GetMinSeverity()) BOOST_LOG_SEV((*logger), boost::log::trivial::info) -#define LOG_WARNING(logger) if(boost::log::trivial::warning >= (logger)->GetMinSeverity()) BOOST_LOG_SEV((*logger), boost::log::trivial::warning) -#define LOG_ERROR(logger) if(boost::log::trivial::error >= (logger)->GetMinSeverity()) BOOST_LOG_SEV((*logger), boost::log::trivial::error) -#define LOG_FATAL(logger) if(boost::log::trivial::fatal >= (logger)->GetMinSeverity()) BOOST_LOG_SEV((*logger), boost::log::trivial::fatal) - -#endif +// ============================================================================ +// 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 __TLOGGER_H__ +#define __TLOGGER_H__ + +#include "TLoggerLevelConfig.h" +#include +#include "TLogFileData.h" +#include "SeverityLevels.h" +#include "TMultiLoggerConfig.h" +#include "TLogRecord.h" + +namespace logger +{ + class TLogger + { + public: + TLogger(const TLogFileDataPtr& spFileData, PCTSTR pszChannel); + + TLogFileDataPtr GetLogFileData() const; + ESeverityLevel GetMinSeverity() const; + TLogRecord OpenLogRecord(ESeverityLevel eLevel) const; + + private: + TLoggerLevelConfigPtr m_spLoggerConfig; + TLogFileDataPtr m_spFileData; + std::wstring m_strChannel; + + friend class TLoggerFactory; + }; + + using TLoggerPtr = std::unique_ptr; + + inline TLoggerPtr MakeLogger(const TLogFileDataPtr& spFileData, PCTSTR pszChannel) + { + return std::make_unique(spFileData, pszChannel); + } + +} + +#define LOG(log, level) for(logger::TLogRecord rec = (log)->OpenLogRecord(level); rec.IsEnabled(); rec.Disable()) rec + +#define LOG_TRACE(log) if(logger::trace >= (log)->GetMinSeverity()) LOG(log, logger::trace) +#define LOG_DEBUG(log) if(logger::debug >= (log)->GetMinSeverity()) LOG(log, logger::debug) +#define LOG_INFO(log) if(logger::info >= (log)->GetMinSeverity()) LOG(log, logger::info) +#define LOG_WARNING(log) if(logger::warning >= (log)->GetMinSeverity()) LOG(log, logger::warning) +#define LOG_ERROR(log) if(logger::error >= (log)->GetMinSeverity()) LOG(log, logger::error) +#define LOG_FATAL(log) if(logger::fatal >= (log)->GetMinSeverity()) LOG(log, logger::fatal) + +#endif Index: src/liblogger/TLoggerFactory.cpp =================================================================== diff -u -N --- src/liblogger/TLoggerFactory.cpp (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/liblogger/TLoggerFactory.cpp (revision 0) @@ -1,38 +0,0 @@ -// ============================================================================ -// 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 "TLoggerFactory.h" -#include "..\libchcore\TCoreException.h" - -namespace chcore -{ - TLoggerFactory::TLoggerFactory(const TSmartPath& pathLog, const TMultiLoggerConfigPtr& spMultiLoggerConfig) : - m_spMultiLoggerConfig(spMultiLoggerConfig), - m_spLogLocation(std::make_shared(pathLog)) - { - if (!spMultiLoggerConfig) - throw TCoreException(eErr_InvalidArgument, L"spMultiLoggerConfig", LOCATION); - } - - std::unique_ptr TLoggerFactory::CreateLogger(PCTSTR pszChannel) - { - TLoggerLevelConfigPtr spConfig = m_spMultiLoggerConfig->GetLoggerConfig(pszChannel); - return std::unique_ptr(new TLogger(spConfig, m_spLogLocation, pszChannel)); - } -} Index: src/liblogger/TLoggerInitializer.cpp =================================================================== diff -u -N --- src/liblogger/TLoggerInitializer.cpp (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/liblogger/TLoggerInitializer.cpp (revision 0) @@ -1,115 +0,0 @@ -// ============================================================================ -// 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 "TLoggerInitializer.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "TMultiFileBackend.h" - -namespace logging = boost::log; -namespace src = boost::log::sources; -namespace sinks = boost::log::sinks; -namespace keywords = boost::log::keywords; -namespace expr = boost::log::expressions; -namespace attrs = boost::log::attributes; - -using namespace boost::log::trivial; - -using Backend = chcore::TMultiFileBackend; -using LogSink = sinks::asynchronous_sink; -using LogSinkPtr = boost::shared_ptr; - -namespace chcore -{ - struct TLoggerInitializer::InternalData - { - LogSinkPtr m_spSink; - }; - - TLoggerInitializer::TLoggerInitializer() : - m_spData(new InternalData) - { - } - - TLoggerInitializer::~TLoggerInitializer() - { - Uninit(); - } - - void TLoggerInitializer::Init(const TSmartPath& pathDirWithLogs, unsigned int uiMaxRotatedFiles, unsigned long long ullMaxLogSize) - { - if (m_bWasInitialized) - return; - - boost::shared_ptr< logging::core > spCore = logging::core::get(); - - logging::add_common_attributes(); - - // sink BACKEND - boost::shared_ptr spBackend = boost::make_shared(nullptr, uiMaxRotatedFiles, ullMaxLogSize); - spBackend->Init(pathDirWithLogs, uiMaxRotatedFiles, ullMaxLogSize); - - // Sink FRONTEND - LogSinkPtr spSink(new LogSink(spBackend)); - - // Set the formatter - spSink->set_formatter - ( - expr::stream - << expr::format_date_time< boost::posix_time::ptime >("TimeStamp", "%Y-%m-%d %H:%M:%S.%f") - << " [" << boost::log::trivial::severity << "] " - << expr::attr< std::wstring >("Channel") << ": " - << expr::wmessage - ); - - std::locale loc = boost::locale::generator()("en_EN.UTF-8"); - spSink->imbue(loc); - - spCore->add_sink(spSink); - - m_spData->m_spSink = spSink; - - m_bWasInitialized = true; - } - - void TLoggerInitializer::Uninit() - { - if (!m_spData->m_spSink || !m_bWasInitialized) - return; - - boost::shared_ptr< logging::core > core = logging::core::get(); - - // Remove the sink from the core, so that no records are passed to it - core->remove_sink(m_spData->m_spSink); - - // Break the feeding loop - m_spData->m_spSink->stop(); - - // Flush all log records that may have left buffered - m_spData->m_spSink->flush(); - - m_spData->m_spSink.reset(); - } -} Index: src/liblogger/TLoggerLevelConfig.cpp =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/liblogger/TLoggerLevelConfig.cpp (.../TLoggerLevelConfig.cpp) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/liblogger/TLoggerLevelConfig.cpp (.../TLoggerLevelConfig.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -1,33 +1,41 @@ -// ============================================================================ -// 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 "TLoggerLevelConfig.h" - -namespace chcore -{ - void TLoggerLevelConfig::SetMinSeverityLevel(boost::log::trivial::severity_level eLevel) - { - m_eMinSeverity = eLevel; - } - - boost::log::trivial::severity_level TLoggerLevelConfig::GetMinSeverityLevel() const - { - return m_eMinSeverity; - } -} +// ============================================================================ +// 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 "TLoggerLevelConfig.h" +#include + +namespace logger +{ + TLoggerLevelConfig::TLoggerLevelConfig(ESeverityLevel eMinSeverity) : + m_eMinSeverity(eMinSeverity) + { + } + + void TLoggerLevelConfig::SetMinSeverityLevel(ESeverityLevel eLevel) + { + boost::unique_lock lock; + m_eMinSeverity = eLevel; + } + + ESeverityLevel TLoggerLevelConfig::GetMinSeverityLevel() const + { + boost::shared_lock lock; + return m_eMinSeverity; + } +} Index: src/liblogger/TLoggerLevelConfig.h =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/liblogger/TLoggerLevelConfig.h (.../TLoggerLevelConfig.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/liblogger/TLoggerLevelConfig.h (.../TLoggerLevelConfig.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -1,39 +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 __TLOGGERCONFIG_H__ -#define __TLOGGERCONFIG_H__ - -#include - -namespace chcore -{ - class TLoggerLevelConfig - { - public: - void SetMinSeverityLevel(boost::log::trivial::severity_level eLevel); - boost::log::trivial::severity_level GetMinSeverityLevel() const; - - private: - boost::log::trivial::severity_level m_eMinSeverity = boost::log::trivial::trace; - }; - - using TLoggerLevelConfigPtr = std::shared_ptr; -} - -#endif +// ============================================================================ +// 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 __TLOGGERCONFIG_H__ +#define __TLOGGERCONFIG_H__ + +#include "SeverityLevels.h" +#include + +namespace logger +{ + class TLoggerLevelConfig + { + public: + TLoggerLevelConfig(ESeverityLevel eMinSeverity = trace); + + void SetMinSeverityLevel(ESeverityLevel eLevel); + ESeverityLevel GetMinSeverityLevel() const; + + private: + ESeverityLevel m_eMinSeverity = trace; + boost::shared_mutex m_mutex; + }; + + using TLoggerLevelConfigPtr = std::shared_ptr; +} + +#endif Index: src/liblogger/TLoggerRotationInfo.cpp =================================================================== diff -u -N --- src/liblogger/TLoggerRotationInfo.cpp (revision 0) +++ src/liblogger/TLoggerRotationInfo.cpp (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -0,0 +1,60 @@ +// ============================================================================ +// 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 "TLoggerRotationInfo.h" +#include + +namespace logger +{ + TLoggerRotationInfo::TLoggerRotationInfo() + { + } + + TLoggerRotationInfo::TLoggerRotationInfo(unsigned long long ullMaxLogSize, unsigned long ulMaxRotatedCount) : + m_ullMaxLogSize(ullMaxLogSize), + m_ulMaxRotatedCount(ulMaxRotatedCount) + { + } + + void TLoggerRotationInfo::SetRotationInfo(unsigned long long ullMaxLogSize, unsigned long ulMaxRotatedCount) + { + boost::unique_lock lock(m_mutex); + m_ullMaxLogSize = ullMaxLogSize; + m_ulMaxRotatedCount = ulMaxRotatedCount; + } + + void TLoggerRotationInfo::GetRotationInfo(unsigned long long& ullMaxLogSize, unsigned long& ulMaxRotatedCount) const + { + boost::shared_lock lock(m_mutex); + ullMaxLogSize = m_ullMaxLogSize; + ulMaxRotatedCount = m_ulMaxRotatedCount; + } + + unsigned long long TLoggerRotationInfo::GetMaxLogSize() const + { + boost::shared_lock lock(m_mutex); + return m_ullMaxLogSize; + } + + unsigned long TLoggerRotationInfo::GetMaxRotatedCount() const + { + boost::shared_lock lock(m_mutex); + return m_ulMaxRotatedCount; + } +} Index: src/liblogger/TLoggerRotationInfo.h =================================================================== diff -u -N --- src/liblogger/TLoggerRotationInfo.h (revision 0) +++ src/liblogger/TLoggerRotationInfo.h (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -0,0 +1,51 @@ +// ============================================================================ +// 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 __TLOGGERROTATIONINFO_H__ +#define __TLOGGERROTATIONINFO_H__ + +#include + +namespace logger +{ + class TLoggerRotationInfo + { + public: + static const unsigned long long DefaultMaxLogSize = 10 * 1024 * 1024; + static const unsigned long DefaultMaxRotatedFiles = 5; + + public: + TLoggerRotationInfo(); + TLoggerRotationInfo(unsigned long long ullMaxLogSize, unsigned long ulMaxRotatedCount); + + void SetRotationInfo(unsigned long long ullMaxLogSize, unsigned long ulMaxRotatedCount); + void GetRotationInfo(unsigned long long& ullMaxLogSize, unsigned long& ulMaxRotatedCount) const; + + unsigned long long GetMaxLogSize() const; + unsigned long GetMaxRotatedCount() const; + + private: + unsigned long long m_ullMaxLogSize = 1024 * 1024; + unsigned long m_ulMaxRotatedCount = 5; + mutable boost::shared_mutex m_mutex; + }; + + using TLoggerRotationInfoPtr = std::shared_ptr; +} + +#endif Index: src/liblogger/TMultiFileBackend.cpp =================================================================== diff -u -N --- src/liblogger/TMultiFileBackend.cpp (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/liblogger/TMultiFileBackend.cpp (revision 0) @@ -1,95 +0,0 @@ -// ============================================================================ -// 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 "TMultiFileBackend.h" -#include "..\libchcore\TTimestampProviderTickCount.h" -#include -#include -#include -#include -#include -#include "..\libchcore\TStringArray.h" -#include "TLoggerLocationConfig.h" - -namespace chcore -{ - TMultiFileBackend::TMultiFileBackend(ITimestampProviderPtr spTimestampProvider, unsigned int uiMaxRotatedFiles, unsigned long long ullMaxLogSize) : - m_spTimestampProvider(spTimestampProvider), - m_logRotator(uiMaxRotatedFiles, ullMaxLogSize) - { - if (!m_spTimestampProvider) - m_spTimestampProvider.reset(new TTimestampProviderTickCount); - } - - void TMultiFileBackend::Init(const TSmartPath& pathDirectory, unsigned int uiMaxRotatedFiles, unsigned long long ullMaxLogSize) - { - SetDirectory(pathDirectory); - m_logRotator.SetLimits(uiMaxRotatedFiles, ullMaxLogSize); - } - - void TMultiFileBackend::consume(const boost::log::record_view& rec, const string_type& formatted_message) - { - if (!m_bInitialized) - return; - - TSmartPath pathLog = GetLogName(rec); - if (pathLog.IsEmpty()) - return; - - TLogSink& sinkData = m_mapLogs.GetSinkData(pathLog); - - HANDLE hFile = GetLogFile(pathLog, sinkData, formatted_message.length()); - if (hFile == INVALID_HANDLE_VALUE) - return; - - string_type strFullMessage = formatted_message + "\r\n"; - - DWORD dwToWrite = boost::numeric_cast(strFullMessage.length()); - DWORD dwWritten = 0; - WriteFile(hFile, strFullMessage.c_str(), dwToWrite, &dwWritten, nullptr); - } - - TSmartPath TMultiFileBackend::GetLogName(const boost::log::record_view &rec) - { - auto attrLogPath = rec.attribute_values().find("LogPath"); - if (attrLogPath == rec.attribute_values().end()) - return TSmartPath(); - - boost::log::value_ref val = boost::log::extract(attrLogPath->second); - if (!val) - return TSmartPath(); - - return val.get()->GetLogPath(); - } - - HANDLE TMultiFileBackend::GetLogFile(const TSmartPath& pathLog, TLogSink& sinkData, size_t stRequiredSpace) - { - m_logRotator.RotateFile(pathLog, sinkData, stRequiredSpace); - - return sinkData.GetFileHandle(); - } - - void TMultiFileBackend::SetDirectory(const TSmartPath& pathDirectory) - { - m_mapLogs.Clear(); - m_logRotator.ScanForLogs(pathDirectory, m_mapLogs); - m_bInitialized = true; - } - -} Index: src/liblogger/TMultiFileBackend.h =================================================================== diff -u -N --- src/liblogger/TMultiFileBackend.h (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/liblogger/TMultiFileBackend.h (revision 0) @@ -1,60 +0,0 @@ -// ============================================================================ -// 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 __TMULTIFILEBACKEND_H__ -#define __TMULTIFILEBACKEND_H__ - -#include -#include "../libchcore/TAutoHandles.h" -#include "../libchcore/ITimestampProvider.h" -#include "../libchcore/TPath.h" -#include "TLogSink.h" -#include "TLogSinkCollection.h" -#include "TLogRotator.h" - -namespace chcore -{ - class TMultiFileBackend : public boost::log::sinks::basic_formatted_sink_backend - { - public: - const unsigned int MaxHandleCacheTime = 60000; - - public: - TMultiFileBackend(ITimestampProviderPtr spTimestampProvider, unsigned int uiMaxRotatedFiles, unsigned long long ullMaxLogSize); - - void Init(const TSmartPath& pathDirectory, unsigned int uiMaxRotatedFiles, unsigned long long ullMaxLogSize); - - void consume(const boost::log::record_view& rec, const string_type& formatted_message); - - private: - void SetDirectory(const TSmartPath& pathDirectory); - - static TSmartPath GetLogName(const boost::log::record_view &rec); - HANDLE GetLogFile(const TSmartPath& pathLog, TLogSink& sinkData, size_t stRequiredSpace); - - private: - unsigned int m_uiHandleCacheTime = MaxHandleCacheTime; - - TLogSinkCollection m_mapLogs; - TLogRotator m_logRotator; - ITimestampProviderPtr m_spTimestampProvider; - bool m_bInitialized = false; - }; -} - -#endif Index: src/liblogger/TMultiLoggerConfig.cpp =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/liblogger/TMultiLoggerConfig.cpp (.../TMultiLoggerConfig.cpp) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/liblogger/TMultiLoggerConfig.cpp (.../TMultiLoggerConfig.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -19,23 +19,44 @@ #include "stdafx.h" #include "TMultiLoggerConfig.h" -namespace chcore +namespace logger { TLoggerLevelConfigPtr TMultiLoggerConfig::GetLoggerConfig(PCTSTR pszChannel, bool bForceAdd) { + boost::upgrade_lock lock(m_mutex); auto iterConfig = m_mapConfigs.find(pszChannel); if (iterConfig == m_mapConfigs.end()) { if (bForceAdd) + { + boost::upgrade_to_unique_lock upgraded_lock(lock); iterConfig = m_mapConfigs.insert(std::make_pair(pszChannel, std::make_shared())).first; + } else + return GetLoggerConfig(lock, L"default", true); + } + + return iterConfig->second; + } + + TLoggerLevelConfigPtr TMultiLoggerConfig::GetLoggerConfig(boost::upgrade_lock& lock, PCTSTR pszChannel, bool bForceAdd) + { + auto iterConfig = m_mapConfigs.find(pszChannel); + if (iterConfig == m_mapConfigs.end()) + { + if (bForceAdd) + { + boost::upgrade_to_unique_lock upgraded_lock(lock); + iterConfig = m_mapConfigs.insert(std::make_pair(pszChannel, std::make_shared())).first; + } + else return GetLoggerConfig(L"default", true); } return iterConfig->second; } - void TMultiLoggerConfig::SetLogLevel(PCTSTR pszChannel, boost::log::trivial::severity_level eLevel) + void TMultiLoggerConfig::SetLogLevel(PCTSTR pszChannel, ESeverityLevel eLevel) { TLoggerLevelConfigPtr spLoggerConfig = GetLoggerConfig(pszChannel, true); spLoggerConfig->SetMinSeverityLevel(eLevel); Index: src/liblogger/TMultiLoggerConfig.h =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/liblogger/TMultiLoggerConfig.h (.../TMultiLoggerConfig.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/liblogger/TMultiLoggerConfig.h (.../TMultiLoggerConfig.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -21,17 +21,23 @@ #include #include "TLoggerLevelConfig.h" +#include +#include -namespace chcore +namespace logger { class TMultiLoggerConfig { public: TLoggerLevelConfigPtr GetLoggerConfig(PCTSTR pszChannel, bool bForceAdd = false); - void SetLogLevel(PCTSTR pszChannel, boost::log::trivial::severity_level eLevel); + void SetLogLevel(PCTSTR pszChannel, ESeverityLevel eLevel); private: + TLoggerLevelConfigPtr GetLoggerConfig(boost::upgrade_lock& lock, PCTSTR pszChannel, bool bForceAdd); + + private: std::map m_mapConfigs; // channel, config + boost::shared_mutex m_mutex; }; using TMultiLoggerConfigPtr = std::shared_ptr; Index: src/liblogger/liblogger.vc140.vcxproj =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/liblogger/liblogger.vc140.vcxproj (.../liblogger.vc140.vcxproj) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/liblogger/liblogger.vc140.vcxproj (.../liblogger.vc140.vcxproj) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -1,495 +1,493 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - Testing Debug - Win32 - - - Testing Debug - x64 - - - Testing Release - Win32 - - - Testing Release - x64 - - - - liblogger - {DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D} - liblogger - Win32Proj - - - - StaticLibrary - v120_xp - Unicode - true - - - StaticLibrary - v120_xp - Unicode - true - - - StaticLibrary - v120_xp - Unicode - - - StaticLibrary - v120_xp - Unicode - - - StaticLibrary - Unicode - true - v120_xp - - - StaticLibrary - Unicode - true - v120_xp - - - StaticLibrary - Unicode - v120_xp - - - StaticLibrary - Unicode - v120_xp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>11.0.51106.1 - - - $(SolutionDir)bin\$(Configuration)\ - $(SolutionDir)intermediate\$(PlatformToolset)\$(Platform)\$(ProjectName)_$(Configuration)\ - true - $(ProjectName)32ud - - - $(SolutionDir)bin\$(Configuration)\ - $(SolutionDir)intermediate\$(PlatformToolset)\$(Platform)\$(ProjectName)_$(Configuration)\ - true - $(ProjectName)32ud - - - $(SolutionDir)bin\$(Configuration)\ - $(SolutionDir)intermediate\$(PlatformToolset)\$(Platform)\$(ProjectName)_$(Configuration)\ - true - $(ProjectName)64ud - NativeRecommendedRules.ruleset - false - - - $(SolutionDir)bin\$(Configuration)\ - $(SolutionDir)intermediate\$(PlatformToolset)\$(Platform)\$(ProjectName)_$(Configuration)\ - true - $(ProjectName)64ud - NativeRecommendedRules.ruleset - false - - - $(SolutionDir)bin\$(Configuration)\ - $(SolutionDir)intermediate\$(PlatformToolset)\$(Platform)\$(ProjectName)_$(Configuration)\ - false - $(ProjectName)32u - - - $(SolutionDir)bin\$(Configuration)\ - $(SolutionDir)intermediate\$(PlatformToolset)\$(Platform)\$(ProjectName)_$(Configuration)\ - false - $(ProjectName)32u - - - $(SolutionDir)bin\$(Configuration)\ - $(SolutionDir)intermediate\$(PlatformToolset)\$(Platform)\$(ProjectName)_$(Configuration)\ - false - $(ProjectName)64u - - - $(SolutionDir)bin\$(Configuration)\ - $(SolutionDir)intermediate\$(PlatformToolset)\$(Platform)\$(ProjectName)_$(Configuration)\ - false - $(ProjectName)64u - - - - Disabled - _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level4 - true - ProgramDatabase - true - ../../ext - NoExtensions - 4512;4714 - - - true - Windows - MachineX86 - "$(OutDir)" - true - - - - - Disabled - _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;TESTING;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level4 - true - ProgramDatabase - true - ..\..\ext\googletest\googletest\include;..\..\ext\googletest\googlemock\include;../../ext - NoExtensions - 4512;4714 - - - true - Windows - MachineX86 - gmock32d.lib;%(AdditionalDependencies) - "$(OutDir)" - true - - - cd "$(TargetDir)" - -if "$(PlatformName)" EQU "x64" goto x64 - -:x32 -"$(SolutionDir)tools\test_runner32.exe" "$(TargetPath)" --gtest_shuffle --gtest_output="xml:$(TargetPath).UnitTests.xml" -goto end - -:x64 -"$(SolutionDir)tools\test_runner64.exe" "$(TargetPath)" --gtest_shuffle --gtest_output="xml:$(TargetPath).UnitTests.xml" -goto end - -:end - - - - - - X64 - - - Disabled - _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level4 - false - ProgramDatabase - 4512;4714 - false - true - ../../ext - - - true - Windows - MachineX64 - "$(OutDir)" - false - - - - - X64 - - - Disabled - _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;TESTING;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Use - Level4 - false - ProgramDatabase - 4512;4714 - false - true - ..\..\ext\googletest\googletest\include;..\..\ext\googletest\googlemock\include;../../ext - - - true - Windows - MachineX64 - gmock64d.lib;%(AdditionalDependencies) - "$(OutDir)" - false - - - cd "$(TargetDir)" - -if "$(PlatformName)" EQU "x64" goto x64 - -:x32 -"$(SolutionDir)tools\test_runner32.exe" "$(TargetPath)" --gtest_shuffle --gtest_output="xml:$(TargetPath).UnitTests.xml" -goto end - -:x64 -"$(SolutionDir)tools\test_runner64.exe" "$(TargetPath)" --gtest_shuffle --gtest_output="xml:$(TargetPath).UnitTests.xml" -goto end - -:end - - - - - - MaxSpeed - true - _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Use - Level4 - true - ProgramDatabase - true - ../../ext - NoExtensions - 4512;4714 - - - true - Windows - true - true - MachineX86 - "$(OutDir)" - true - - - - - MaxSpeed - true - _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;TESTING;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Use - Level4 - true - ProgramDatabase - true - ..\..\ext\googletest\googletest\include;..\..\ext\googletest\googlemock\include;../../ext - NoExtensions - 4512;4714 - - - true - Windows - true - true - MachineX86 - gmock32.lib;%(AdditionalDependencies) - "$(OutDir)" - true - - - cd "$(TargetDir)" - -if "$(PlatformName)" EQU "x64" goto x64 - -:x32 -"$(SolutionDir)tools\test_runner32.exe" "$(TargetPath)" --gtest_shuffle --gtest_output="xml:$(TargetPath).UnitTests.xml" -goto end - -:x64 -"$(SolutionDir)tools\test_runner64.exe" "$(TargetPath)" --gtest_shuffle --gtest_output="xml:$(TargetPath).UnitTests.xml" -goto end - -:end - - - - - - X64 - - - MaxSpeed - true - _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Use - Level4 - true - ProgramDatabase - true - ../../ext - 4512;4714 - - - true - Windows - true - true - MachineX64 - "$(OutDir)" - false - - - - - X64 - - - MaxSpeed - true - _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;TESTING;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Use - Level4 - true - ProgramDatabase - true - ..\..\ext\googletest\googletest\include;..\..\ext\googletest\googlemock\include;../../ext - 4512;4714 - - - true - Windows - true - true - MachineX64 - gmock64.lib;%(AdditionalDependencies) - "$(OutDir)" - false - - - cd "$(TargetDir)" - -if "$(PlatformName)" EQU "x64" goto x64 - -:x32 -"$(SolutionDir)tools\test_runner32.exe" "$(TargetPath)" --gtest_shuffle --gtest_output="xml:$(TargetPath).UnitTests.xml" -goto end - -:x64 -"$(SolutionDir)tools\test_runner64.exe" "$(TargetPath)" --gtest_shuffle --gtest_output="xml:$(TargetPath).UnitTests.xml" -goto end - -:end - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - Create - Create - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + Testing Debug + Win32 + + + Testing Debug + x64 + + + Testing Release + Win32 + + + Testing Release + x64 + + + + liblogger + {DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D} + liblogger + Win32Proj + + + + StaticLibrary + v120_xp + Unicode + true + + + StaticLibrary + v120_xp + Unicode + true + + + StaticLibrary + v120_xp + Unicode + + + StaticLibrary + v120_xp + Unicode + + + StaticLibrary + Unicode + true + v120_xp + + + StaticLibrary + Unicode + true + v120_xp + + + StaticLibrary + Unicode + v120_xp + + + StaticLibrary + Unicode + v120_xp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>11.0.51106.1 + + + $(SolutionDir)bin\$(Configuration)\ + $(SolutionDir)intermediate\$(PlatformToolset)\$(Platform)\$(ProjectName)_$(Configuration)\ + true + $(ProjectName)32ud + + + $(SolutionDir)bin\$(Configuration)\ + $(SolutionDir)intermediate\$(PlatformToolset)\$(Platform)\$(ProjectName)_$(Configuration)\ + true + $(ProjectName)32ud + + + $(SolutionDir)bin\$(Configuration)\ + $(SolutionDir)intermediate\$(PlatformToolset)\$(Platform)\$(ProjectName)_$(Configuration)\ + true + $(ProjectName)64ud + NativeRecommendedRules.ruleset + false + + + $(SolutionDir)bin\$(Configuration)\ + $(SolutionDir)intermediate\$(PlatformToolset)\$(Platform)\$(ProjectName)_$(Configuration)\ + true + $(ProjectName)64ud + NativeRecommendedRules.ruleset + false + + + $(SolutionDir)bin\$(Configuration)\ + $(SolutionDir)intermediate\$(PlatformToolset)\$(Platform)\$(ProjectName)_$(Configuration)\ + false + $(ProjectName)32u + + + $(SolutionDir)bin\$(Configuration)\ + $(SolutionDir)intermediate\$(PlatformToolset)\$(Platform)\$(ProjectName)_$(Configuration)\ + false + $(ProjectName)32u + + + $(SolutionDir)bin\$(Configuration)\ + $(SolutionDir)intermediate\$(PlatformToolset)\$(Platform)\$(ProjectName)_$(Configuration)\ + false + $(ProjectName)64u + + + $(SolutionDir)bin\$(Configuration)\ + $(SolutionDir)intermediate\$(PlatformToolset)\$(Platform)\$(ProjectName)_$(Configuration)\ + false + $(ProjectName)64u + + + + Disabled + _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + Level4 + true + ProgramDatabase + true + ../../ext + NoExtensions + 4512;4714 + + + true + Windows + MachineX86 + "$(OutDir)" + true + + + + + Disabled + _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;TESTING;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + Level4 + true + ProgramDatabase + true + ..\..\ext\googletest\googletest\include;..\..\ext\googletest\googlemock\include;../../ext + NoExtensions + 4512;4714 + + + true + Windows + MachineX86 + gmock32d.lib;%(AdditionalDependencies) + "$(OutDir)" + true + + + cd "$(TargetDir)" + +if "$(PlatformName)" EQU "x64" goto x64 + +:x32 +"$(SolutionDir)tools\test_runner32.exe" "$(TargetPath)" --gtest_shuffle --gtest_output="xml:$(TargetPath).UnitTests.xml" +goto end + +:x64 +"$(SolutionDir)tools\test_runner64.exe" "$(TargetPath)" --gtest_shuffle --gtest_output="xml:$(TargetPath).UnitTests.xml" +goto end + +:end + + + + + + X64 + + + Disabled + _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + Level4 + false + ProgramDatabase + 4512;4714 + false + true + ../../ext + + + true + Windows + MachineX64 + "$(OutDir)" + false + + + + + X64 + + + Disabled + _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;TESTING;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + Level4 + false + ProgramDatabase + 4512;4714 + false + true + ..\..\ext\googletest\googletest\include;..\..\ext\googletest\googlemock\include;../../ext + + + true + Windows + MachineX64 + gmock64d.lib;%(AdditionalDependencies) + "$(OutDir)" + false + + + cd "$(TargetDir)" + +if "$(PlatformName)" EQU "x64" goto x64 + +:x32 +"$(SolutionDir)tools\test_runner32.exe" "$(TargetPath)" --gtest_shuffle --gtest_output="xml:$(TargetPath).UnitTests.xml" +goto end + +:x64 +"$(SolutionDir)tools\test_runner64.exe" "$(TargetPath)" --gtest_shuffle --gtest_output="xml:$(TargetPath).UnitTests.xml" +goto end + +:end + + + + + + MaxSpeed + true + _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Use + Level4 + true + ProgramDatabase + true + ../../ext + NoExtensions + 4512;4714 + + + true + Windows + true + true + MachineX86 + "$(OutDir)" + true + + + + + MaxSpeed + true + _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;TESTING;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Use + Level4 + true + ProgramDatabase + true + ..\..\ext\googletest\googletest\include;..\..\ext\googletest\googlemock\include;../../ext + NoExtensions + 4512;4714 + + + true + Windows + true + true + MachineX86 + gmock32.lib;%(AdditionalDependencies) + "$(OutDir)" + true + + + cd "$(TargetDir)" + +if "$(PlatformName)" EQU "x64" goto x64 + +:x32 +"$(SolutionDir)tools\test_runner32.exe" "$(TargetPath)" --gtest_shuffle --gtest_output="xml:$(TargetPath).UnitTests.xml" +goto end + +:x64 +"$(SolutionDir)tools\test_runner64.exe" "$(TargetPath)" --gtest_shuffle --gtest_output="xml:$(TargetPath).UnitTests.xml" +goto end + +:end + + + + + + X64 + + + MaxSpeed + true + _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Use + Level4 + true + ProgramDatabase + true + ../../ext + 4512;4714 + + + true + Windows + true + true + MachineX64 + "$(OutDir)" + false + + + + + X64 + + + MaxSpeed + true + _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;TESTING;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Use + Level4 + true + ProgramDatabase + true + ..\..\ext\googletest\googletest\include;..\..\ext\googletest\googlemock\include;../../ext + 4512;4714 + + + true + Windows + true + true + MachineX64 + gmock64.lib;%(AdditionalDependencies) + "$(OutDir)" + false + + + cd "$(TargetDir)" + +if "$(PlatformName)" EQU "x64" goto x64 + +:x32 +"$(SolutionDir)tools\test_runner32.exe" "$(TargetPath)" --gtest_shuffle --gtest_output="xml:$(TargetPath).UnitTests.xml" +goto end + +:x64 +"$(SolutionDir)tools\test_runner64.exe" "$(TargetPath)" --gtest_shuffle --gtest_output="xml:$(TargetPath).UnitTests.xml" +goto end + +:end + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + Create + Create + Create + Create + + + + + + + + + + + + + \ No newline at end of file Index: src/liblogger/liblogger.vc140.vcxproj.filters =================================================================== diff -u -N -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 -r12b36349f6214befeace08efa9acc7e03be0d847 --- src/liblogger/liblogger.vc140.vcxproj.filters (.../liblogger.vc140.vcxproj.filters) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) +++ src/liblogger/liblogger.vc140.vcxproj.filters (.../liblogger.vc140.vcxproj.filters) (revision 12b36349f6214befeace08efa9acc7e03be0d847) @@ -1,86 +1,83 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {e160d2cd-2a88-40ef-97b4-6b7d3b7ed6b1} - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files\Library files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files\Library files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {e160d2cd-2a88-40ef-97b4-6b7d3b7ed6b1} + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + {eb9df11f-3ddf-4f04-bc60-920c9bec2694} + + + + + Source Files\Library files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\Utils + + + + + Source Files\Library files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\Utils + + \ No newline at end of file