Index: ch.vc140.sln =================================================================== diff -u -N -r4a481bbe77043e0bda2435c6d62a02700b3e46c5 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- ch.vc140.sln (.../ch.vc140.sln) (revision 4a481bbe77043e0bda2435c6d62a02700b3e46c5) +++ ch.vc140.sln (.../ch.vc140.sln) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -32,6 +32,8 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gmock", "ext\googletest\gmock.vc140.vcxproj", "{D98F2D98-2352-4303-93EE-A5430C4E98AB}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblogger", "src\liblogger\liblogger.vc140.vcxproj", "{DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -156,6 +158,22 @@ {D98F2D98-2352-4303-93EE-A5430C4E98AB}.Testing Release|Win32.Build.0 = Testing Release|Win32 {D98F2D98-2352-4303-93EE-A5430C4E98AB}.Testing Release|x64.ActiveCfg = Testing Release|x64 {D98F2D98-2352-4303-93EE-A5430C4E98AB}.Testing Release|x64.Build.0 = Testing Release|x64 + {DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D}.Debug|Win32.ActiveCfg = Debug|Win32 + {DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D}.Debug|Win32.Build.0 = Debug|Win32 + {DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D}.Debug|x64.ActiveCfg = Debug|x64 + {DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D}.Debug|x64.Build.0 = Debug|x64 + {DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D}.Release|Win32.ActiveCfg = Release|Win32 + {DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D}.Release|Win32.Build.0 = Release|Win32 + {DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D}.Release|x64.ActiveCfg = Release|x64 + {DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D}.Release|x64.Build.0 = Release|x64 + {DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D}.Testing Debug|Win32.ActiveCfg = Testing Debug|Win32 + {DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D}.Testing Debug|Win32.Build.0 = Testing Debug|Win32 + {DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D}.Testing Debug|x64.ActiveCfg = Testing Debug|x64 + {DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D}.Testing Debug|x64.Build.0 = Testing Debug|x64 + {DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D}.Testing Release|Win32.ActiveCfg = Testing Release|Win32 + {DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D}.Testing Release|Win32.Build.0 = Testing Release|Win32 + {DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D}.Testing Release|x64.ActiveCfg = Testing Release|x64 + {DF9957D4-3D95-4AC3-AD3F-DCBEA058F79D}.Testing Release|x64.Build.0 = Testing Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Index: src/ch/AsyncHttpFile.cpp =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/ch/AsyncHttpFile.cpp (.../AsyncHttpFile.cpp) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/ch/AsyncHttpFile.cpp (.../AsyncHttpFile.cpp) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -18,7 +18,7 @@ // ============================================================================ #include "stdafx.h" #include "AsyncHttpFile.h" -#include "../common/TLogger.h" +#include "../liblogger/TLogger.h" #include "ch.h" // timeout used with waiting for events (avoiding hangs) Index: src/ch/UpdaterDlg.cpp =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/ch/UpdaterDlg.cpp (.../UpdaterDlg.cpp) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/ch/UpdaterDlg.cpp (.../UpdaterDlg.cpp) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -12,7 +12,7 @@ #include "WindowsVersion.h" #include "resource.h" #include "CfgProperties.h" -#include "../common/TLogger.h" +#include "../liblogger/TLogger.h" #define UPDATER_TIMER 639 Index: src/ch/ch.cpp =================================================================== diff -u -N -rb8b97b70743c49fcc2aee0db4cb7118db5e26dab -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/ch/ch.cpp (.../ch.cpp) (revision b8b97b70743c49fcc2aee0db4cb7118db5e26dab) +++ src/ch/ch.cpp (.../ch.cpp) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -43,7 +43,7 @@ #include "TMsgBox.h" #include "../libchcore/TWin32ErrorFormatter.h" #include "resource.h" -#include "../common/TLogger.h" +#include "../liblogger/TLogger.h" #ifdef _DEBUG #define new DEBUG_NEW Index: src/ch/ch.h =================================================================== diff -u -N -rb8b97b70743c49fcc2aee0db4cb7118db5e26dab -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/ch/ch.h (.../ch.h) (revision b8b97b70743c49fcc2aee0db4cb7118db5e26dab) +++ src/ch/ch.h (.../ch.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -24,10 +24,10 @@ #include "../libchcore/TConfig.h" #include "TShellExtensionClient.h" #include "TCommandLineParser.h" -#include "../common/TLogger.h" -#include "../common/TLoggerInitializer.h" +#include "../liblogger/TLogger.h" +#include "../liblogger/TLoggerInitializer.h" #include "../libchcore/TCoreEngine.h" -#include "../common/TLoggerFactory.h" +#include "../liblogger/TLoggerFactory.h" class CCopyHandlerApp : public CWinApp, public CAppHelper { Index: src/ch/ch.vc140.vcxproj =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/ch/ch.vc140.vcxproj (.../ch.vc140.vcxproj) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/ch/ch.vc140.vcxproj (.../ch.vc140.vcxproj) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -510,16 +510,6 @@ - - - - - - - - - - @@ -772,25 +762,6 @@ NotUsing NotUsing - - 4512;4714 - 4512;4714 - 4512;4714 - 4512;4714 - 4512;4714 - 4512;4714 - 4512;4714 - 4512;4714 - - - - - - - - - - @@ -2011,6 +1982,9 @@ {dd1f3242-7ee4-4f41-8b8d-d833300c445f} + + {df9957d4-3d95-4ac3-ad3f-dcbea058f79d} + Index: src/ch/ch.vc140.vcxproj.filters =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/ch/ch.vc140.vcxproj.filters (.../ch.vc140.vcxproj.filters) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/ch/ch.vc140.vcxproj.filters (.../ch.vc140.vcxproj.filters) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -63,9 +63,6 @@ {2e2638f2-07f6-4472-bd2d-32151a7ef9ce} - - {475febbf-e9ec-4293-a92f-d31c3f8c8072} - @@ -248,36 +245,6 @@ Source Files\Core - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - @@ -451,36 +418,6 @@ Source Files\Core - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - Index: src/libchcore/TCoreEngine.h =================================================================== diff -u -N -rb8b97b70743c49fcc2aee0db4cb7118db5e26dab -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/libchcore/TCoreEngine.h (.../TCoreEngine.h) (revision b8b97b70743c49fcc2aee0db4cb7118db5e26dab) +++ src/libchcore/TCoreEngine.h (.../TCoreEngine.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -20,7 +20,7 @@ #define __TCOREENGINE_H__ #include "libchcore.h" -#include "../common/TLoggerInitializer.h" +#include "../liblogger/TLoggerInitializer.h" namespace chcore { Index: src/libchcore/TFilesystemFeedbackWrapper.h =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/libchcore/TFilesystemFeedbackWrapper.h (.../TFilesystemFeedbackWrapper.h) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TFilesystemFeedbackWrapper.h (.../TFilesystemFeedbackWrapper.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -21,8 +21,8 @@ #include "IFilesystem.h" #include "TSubTaskBase.h" -#include "../common/TLogger.h" -#include "../common/TLoggerFactory.h" +#include "../liblogger/TLogger.h" +#include "../liblogger/TLoggerFactory.h" namespace chcore { Index: src/libchcore/TFilesystemFileFeedbackWrapper.h =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/libchcore/TFilesystemFileFeedbackWrapper.h (.../TFilesystemFileFeedbackWrapper.h) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TFilesystemFileFeedbackWrapper.h (.../TFilesystemFileFeedbackWrapper.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -23,8 +23,8 @@ #include "TSubTaskBase.h" #include "IFeedbackHandler.h" #include "IFilesystem.h" -#include "../common/TLogger.h" -#include "../common/TLoggerFactory.h" +#include "../liblogger/TLogger.h" +#include "../liblogger/TLoggerFactory.h" namespace chcore { Index: src/libchcore/TPath.h =================================================================== diff -u -N -rf866db90e4b058a4f2e13cc6cf076d1e0bf2d956 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/libchcore/TPath.h (.../TPath.h) (revision f866db90e4b058a4f2e13cc6cf076d1e0bf2d956) +++ src/libchcore/TPath.h (.../TPath.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -30,7 +30,7 @@ class LIBCHCORE_API TSmartPath { protected: - BOOST_STATIC_CONSTANT(bool, DefaultCaseSensitivity = false); + static const bool DefaultCaseSensitivity = false; public: // Construction/destruction Index: src/libchcore/TStringArray.h =================================================================== diff -u -N -rcb4e9d4b60d62b25ae2cf556c0642601af56c787 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/libchcore/TStringArray.h (.../TStringArray.h) (revision cb4e9d4b60d62b25ae2cf556c0642601af56c787) +++ src/libchcore/TStringArray.h (.../TStringArray.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -25,6 +25,7 @@ #include "TString.h" #include "libchcore.h" +#include namespace chcore { Index: src/libchcore/TSubTaskContext.h =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/libchcore/TSubTaskContext.h (.../TSubTaskContext.h) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TSubTaskContext.h (.../TSubTaskContext.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -29,7 +29,7 @@ #include "TBasePathData.h" #include "TFileInfoArray.h" #include "IFilesystem.h" -#include "..\common\TLoggerFactory.h" +#include "..\liblogger\TLoggerFactory.h" namespace chcore { Index: src/libchcore/TSubTaskCopyMove.h =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/libchcore/TSubTaskCopyMove.h (.../TSubTaskCopyMove.h) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TSubTaskCopyMove.h (.../TSubTaskCopyMove.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -28,7 +28,7 @@ #include "CommonDataTypes.h" #include "TBufferSizes.h" #include "IFilesystemFile.h" -#include "../common/TLogger.h" +#include "../liblogger/TLogger.h" namespace chcore { Index: src/libchcore/TSubTaskDelete.h =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/libchcore/TSubTaskDelete.h (.../TSubTaskDelete.h) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TSubTaskDelete.h (.../TSubTaskDelete.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -25,7 +25,7 @@ #include "libchcore.h" #include "TSubTaskBase.h" -#include "../common/TLogger.h" +#include "../liblogger/TLogger.h" namespace chcore { Index: src/libchcore/TSubTaskFastMove.h =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/libchcore/TSubTaskFastMove.h (.../TSubTaskFastMove.h) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TSubTaskFastMove.h (.../TSubTaskFastMove.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -25,7 +25,7 @@ #include "libchcore.h" #include "TSubTaskBase.h" -#include "../Common/TLogger.h" +#include "../liblogger/TLogger.h" namespace chcore { Index: src/libchcore/TSubTaskScanDirectory.h =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/libchcore/TSubTaskScanDirectory.h (.../TSubTaskScanDirectory.h) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TSubTaskScanDirectory.h (.../TSubTaskScanDirectory.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -27,7 +27,7 @@ #include "TSubTaskBase.h" #include "TPath.h" #include "TBasePathData.h" -#include "../common/TLogger.h" +#include "../liblogger/TLogger.h" namespace chcore { Index: src/libchcore/TTask.h =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/libchcore/TTask.h (.../TTask.h) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TTask.h (.../TTask.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -34,8 +34,8 @@ #include "TTaskBaseData.h" #include #include "IFilesystem.h" -#include "..\Common\TLogger.h" -#include "..\common\TLoggerFactory.h" +#include "..\liblogger\TLogger.h" +#include "..\liblogger\TLoggerFactory.h" namespace chcore { Index: src/libchcore/TTaskConfigVerifier.cpp =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/libchcore/TTaskConfigVerifier.cpp (.../TTaskConfigVerifier.cpp) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TTaskConfigVerifier.cpp (.../TTaskConfigVerifier.cpp) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -20,7 +20,7 @@ #include "TTaskConfigVerifier.h" #include "TTaskConfiguration.h" #include -#include "..\Common\TLogger.h" +#include "..\liblogger\TLogger.h" namespace chcore { Index: src/libchcore/TTaskConfigVerifier.h =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/libchcore/TTaskConfigVerifier.h (.../TTaskConfigVerifier.h) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TTaskConfigVerifier.h (.../TTaskConfigVerifier.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -19,7 +19,7 @@ #ifndef __TTASKCONFIGVERIFIER_H__ #define __TTASKCONFIGVERIFIER_H__ -#include "..\common\TLogger.h" +#include "..\liblogger\TLogger.h" namespace chcore { Index: src/libchcore/TTaskManager.h =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/libchcore/TTaskManager.h (.../TTaskManager.h) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/TTaskManager.h (.../TTaskManager.h) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -27,7 +27,7 @@ #include "ISerializer.h" #include "ISerializerFactory.h" #include "TObsoleteFiles.h" -#include "..\common\TMultiLoggerConfig.h" +#include "..\liblogger\TMultiLoggerConfig.h" namespace chcore { Index: src/libchcore/libchcore.vc140.vcxproj =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/libchcore/libchcore.vc140.vcxproj (.../libchcore.vc140.vcxproj) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/libchcore.vc140.vcxproj (.../libchcore.vc140.vcxproj) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -455,16 +455,6 @@ - - - - - - - - - - @@ -606,16 +596,6 @@ NotUsing NotUsing - - - - - - - - - - @@ -876,6 +856,9 @@ {d41831f5-b2a5-4c92-9f15-1d9ab04722cc} + + {df9957d4-3d95-4ac3-ad3f-dcbea058f79d} + Index: src/libchcore/libchcore.vc140.vcxproj.filters =================================================================== diff -u -N -r62d767936f1675e1db51174f53c91484fe691937 -rcca174e74e108de1f5729e4cc6c46d2b9a5e25a7 --- src/libchcore/libchcore.vc140.vcxproj.filters (.../libchcore.vc140.vcxproj.filters) (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/libchcore/libchcore.vc140.vcxproj.filters (.../libchcore.vc140.vcxproj.filters) (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -84,9 +84,6 @@ {0bd6a559-b992-4f1d-abe6-f8105a9d5f50} - - {4a321c2c-525d-4a77-bad6-d01210bba74c} - @@ -461,39 +458,9 @@ Source Files\Task Config - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - Source Files\Library files - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - @@ -874,38 +841,8 @@ Tests\TaskConfig - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - Source Files\Library files - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - - - Source Files\Shared\Logging - \ No newline at end of file Index: src/liblogger/TLogRotator.cpp =================================================================== diff -u -N --- src/liblogger/TLogRotator.cpp (revision 0) +++ src/liblogger/TLogRotator.cpp (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,97 @@ +// ============================================================================ +// 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/common/TLogRotator.cpp =================================================================== diff -u -N --- src/common/TLogRotator.cpp (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/common/TLogRotator.cpp (revision 0) @@ -1,96 +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" - -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/TLogRotator.h =================================================================== diff -u -N --- src/liblogger/TLogRotator.h (revision 0) +++ src/liblogger/TLogRotator.h (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,45 @@ +// ============================================================================ +// 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 __TLOGROTATOR_H__ +#define __TLOGROTATOR_H__ + +#include "..\libchcore\TPath.h" +#include "TLogSink.h" + +namespace chcore +{ + class TLogSinkCollection; + + class TLogRotator + { + public: + TLogRotator(unsigned int uiMaxRotatedFiles, unsigned long long ullMaxLogSize); + + void SetLimits(unsigned int uiMaxRotatedFiles, unsigned long long ullMaxLogSize); + + void RotateFile(const TSmartPath& pathLog, TLogSink& sinkData, size_t stRequiredSpace); + static void ScanForLogs(const TSmartPath& pathDir, TLogSinkCollection& rCollection); + + private: + unsigned int m_uiMaxRotatedFiles = 0; + unsigned long long m_ullMaxLogSize = 0; + }; +} + +#endif Index: src/common/TLogRotator.h =================================================================== diff -u -N --- src/common/TLogRotator.h (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/common/TLogRotator.h (revision 0) @@ -1,45 +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 __TLOGROTATOR_H__ -#define __TLOGROTATOR_H__ - -#include "..\libchcore\TPath.h" -#include "TLogSink.h" - -namespace chcore -{ - class TLogSinkCollection; - - class TLogRotator - { - public: - TLogRotator(unsigned int uiMaxRotatedFiles, unsigned long long ullMaxLogSize); - - void SetLimits(unsigned int uiMaxRotatedFiles, unsigned long long ullMaxLogSize); - - void RotateFile(const TSmartPath& pathLog, TLogSink& sinkData, size_t stRequiredSpace); - static void ScanForLogs(const TSmartPath& pathDir, TLogSinkCollection& rCollection); - - private: - unsigned int m_uiMaxRotatedFiles = 0; - unsigned long long m_ullMaxLogSize = 0; - }; -} - -#endif Index: src/liblogger/TLogSink.cpp =================================================================== diff -u -N --- src/liblogger/TLogSink.cpp (revision 0) +++ src/liblogger/TLogSink.cpp (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,84 @@ +// ============================================================================ +// 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/common/TLogSink.cpp =================================================================== diff -u -N --- src/common/TLogSink.cpp (revision b8b97b70743c49fcc2aee0db4cb7118db5e26dab) +++ src/common/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/TLogSink.h =================================================================== diff -u -N --- src/liblogger/TLogSink.h (revision 0) +++ src/liblogger/TLogSink.h (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,50 @@ +// ============================================================================ +// 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 __TLOGSINK_H__ +#define __TLOGSINK_H__ + +#include "..\libchcore\TPath.h" +#include "..\libchcore\TAutoHandles.h" +#include + +namespace chcore +{ + class TLogSink + { + public: + TLogSink(const chcore::TSmartPath& pathLog); + + HANDLE GetFileHandle(); + unsigned long long GetCurrentLogSize(); + + void CloseLogFile(); + void CloseIfTimedOut(unsigned long long ullCurrentTimestamp, unsigned long long ullMaxHandleCacheTime); + + void AddRotatedFile(const TSmartPath& rPath); + void RemoveObsoleteRotatedLogs(unsigned int uiMaxRotatedFiles); + + private: + chcore::TSmartPath m_pathLog; + chcore::TAutoFileHandle m_handleFile; + unsigned long long m_ullLastUsageTimestamp = 0; + std::set m_setRotatedFiles; + }; +} + +#endif Index: src/common/TLogSink.h =================================================================== diff -u -N --- src/common/TLogSink.h (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/common/TLogSink.h (revision 0) @@ -1,50 +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 __TLOGSINK_H__ -#define __TLOGSINK_H__ - -#include "..\libchcore\TPath.h" -#include "..\libchcore\TAutoHandles.h" -#include - -namespace chcore -{ - class TLogSink - { - public: - TLogSink(const chcore::TSmartPath& pathLog); - - HANDLE GetFileHandle(); - unsigned long long GetCurrentLogSize(); - - void CloseLogFile(); - void CloseIfTimedOut(unsigned long long ullCurrentTimestamp, unsigned long long ullMaxHandleCacheTime); - - void AddRotatedFile(const TSmartPath& rPath); - void RemoveObsoleteRotatedLogs(unsigned int uiMaxRotatedFiles); - - private: - chcore::TSmartPath m_pathLog; - chcore::TAutoFileHandle m_handleFile; - unsigned long long m_ullLastUsageTimestamp = 0; - std::set m_setRotatedFiles; - }; -} - -#endif Index: src/liblogger/TLogSinkCollection.cpp =================================================================== diff -u -N --- src/liblogger/TLogSinkCollection.cpp (revision 0) +++ src/liblogger/TLogSinkCollection.cpp (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,81 @@ +// ============================================================================ +// 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/common/TLogSinkCollection.cpp =================================================================== diff -u -N --- src/common/TLogSinkCollection.cpp (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/common/TLogSinkCollection.cpp (revision 0) @@ -1,80 +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" - -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/TLogSinkCollection.h =================================================================== diff -u -N --- src/liblogger/TLogSinkCollection.h (revision 0) +++ src/liblogger/TLogSinkCollection.h (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,45 @@ +// ============================================================================ +// 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 __TLOGSINKCOLLECTION_H__ +#define __TLOGSINKCOLLECTION_H__ + +#include +#include "..\libchcore\TPath.h" +#include "TLogSink.h" + +namespace chcore +{ + class TLogSinkCollection + { + public: + TLogSinkCollection(); + + void AddPath(const TSmartPath& rPath); + TLogSink& GetSinkData(const TSmartPath& path); + + void Clear(); + + void CloseExpiredFiles(unsigned long long ullCurrentTimestamp, unsigned long long ullMaxHandleCacheTime); + + private: + std::map m_mapLogs; + }; +} + +#endif Index: src/common/TLogSinkCollection.h =================================================================== diff -u -N --- src/common/TLogSinkCollection.h (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/common/TLogSinkCollection.h (revision 0) @@ -1,45 +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 __TLOGSINKCOLLECTION_H__ -#define __TLOGSINKCOLLECTION_H__ - -#include -#include "..\libchcore\TPath.h" -#include "TLogSink.h" - -namespace chcore -{ - class TLogSinkCollection - { - public: - TLogSinkCollection(); - - void AddPath(const TSmartPath& rPath); - TLogSink& GetSinkData(const TSmartPath& path); - - void Clear(); - - void CloseExpiredFiles(unsigned long long ullCurrentTimestamp, unsigned long long ullMaxHandleCacheTime); - - private: - std::map m_mapLogs; - }; -} - -#endif Index: src/liblogger/TLogger.cpp =================================================================== diff -u -N --- src/liblogger/TLogger.cpp (revision 0) +++ src/liblogger/TLogger.cpp (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,44 @@ +// ============================================================================ +// 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(); + } +} Index: src/common/TLogger.cpp =================================================================== diff -u -N --- src/common/TLogger.cpp (revision ffbc773697bd08220163bf1e4491a34376b0f61c) +++ src/common/TLogger.cpp (revision 0) @@ -1,44 +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 "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(); - } -} Index: src/liblogger/TLogger.h =================================================================== diff -u -N --- src/liblogger/TLogger.h (revision 0) +++ src/liblogger/TLogger.h (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -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 __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 Index: src/common/TLogger.h =================================================================== diff -u -N --- src/common/TLogger.h (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/common/TLogger.h (revision 0) @@ -1,58 +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 __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 Index: src/liblogger/TLoggerFactory.cpp =================================================================== diff -u -N --- src/liblogger/TLoggerFactory.cpp (revision 0) +++ src/liblogger/TLoggerFactory.cpp (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -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 "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/common/TLoggerFactory.cpp =================================================================== diff -u -N --- src/common/TLoggerFactory.cpp (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/common/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/TLoggerFactory.h =================================================================== diff -u -N --- src/liblogger/TLoggerFactory.h (revision 0) +++ src/liblogger/TLoggerFactory.h (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,44 @@ +// ============================================================================ +// 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 __TLOGGERFACTORY_H__ +#define __TLOGGERFACTORY_H__ + +#include "TMultiLoggerConfig.h" +#include "TLogger.h" +#include "TLoggerLocationConfig.h" +#include + +namespace chcore +{ + class TLoggerFactory + { + public: + TLoggerFactory(const TSmartPath& pathLog, const TMultiLoggerConfigPtr& spMultiLoggerConfig); + + std::unique_ptr CreateLogger(PCTSTR pszChannel); + + private: + TMultiLoggerConfigPtr m_spMultiLoggerConfig; + TLoggerLocationConfigPtr m_spLogLocation; + }; + + using TLoggerFactoryPtr = std::shared_ptr; +} + +#endif Index: src/common/TLoggerFactory.h =================================================================== diff -u -N --- src/common/TLoggerFactory.h (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/common/TLoggerFactory.h (revision 0) @@ -1,44 +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 __TLOGGERFACTORY_H__ -#define __TLOGGERFACTORY_H__ - -#include "TMultiLoggerConfig.h" -#include "TLogger.h" -#include "TLoggerLocationConfig.h" -#include - -namespace chcore -{ - class TLoggerFactory - { - public: - TLoggerFactory(const TSmartPath& pathLog, const TMultiLoggerConfigPtr& spMultiLoggerConfig); - - std::unique_ptr CreateLogger(PCTSTR pszChannel); - - private: - TMultiLoggerConfigPtr m_spMultiLoggerConfig; - TLoggerLocationConfigPtr m_spLogLocation; - }; - - using TLoggerFactoryPtr = std::shared_ptr; -} - -#endif Index: src/liblogger/TLoggerInitializer.cpp =================================================================== diff -u -N --- src/liblogger/TLoggerInitializer.cpp (revision 0) +++ src/liblogger/TLoggerInitializer.cpp (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,115 @@ +// ============================================================================ +// 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/common/TLoggerInitializer.cpp =================================================================== diff -u -N --- src/common/TLoggerInitializer.cpp (revision b8b97b70743c49fcc2aee0db4cb7118db5e26dab) +++ src/common/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/TLoggerInitializer.h =================================================================== diff -u -N --- src/liblogger/TLoggerInitializer.h (revision 0) +++ src/liblogger/TLoggerInitializer.h (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,42 @@ +// ============================================================================ +// 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 __TLOGGERINITIALIZER_H__ +#define __TLOGGERINITIALIZER_H__ + +#include "..\libchcore\TPath.h" + +namespace chcore +{ + class TLoggerInitializer + { + public: + TLoggerInitializer(); + ~TLoggerInitializer(); + + void Init(const TSmartPath& pathDirWithLogs, unsigned int uiMaxRotatedFiles, unsigned long long ullMaxLogSize); + void Uninit(); + + private: + struct InternalData; + std::unique_ptr m_spData; + bool m_bWasInitialized = false; + }; +} + +#endif Index: src/common/TLoggerInitializer.h =================================================================== diff -u -N --- src/common/TLoggerInitializer.h (revision b8b97b70743c49fcc2aee0db4cb7118db5e26dab) +++ src/common/TLoggerInitializer.h (revision 0) @@ -1,42 +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 __TLOGGERINITIALIZER_H__ -#define __TLOGGERINITIALIZER_H__ - -#include "..\libchcore\TPath.h" - -namespace chcore -{ - class TLoggerInitializer - { - public: - TLoggerInitializer(); - ~TLoggerInitializer(); - - void Init(const TSmartPath& pathDirWithLogs, unsigned int uiMaxRotatedFiles, unsigned long long ullMaxLogSize); - void Uninit(); - - private: - struct InternalData; - std::unique_ptr m_spData; - bool m_bWasInitialized = false; - }; -} - -#endif Index: src/liblogger/TLoggerLevelConfig.cpp =================================================================== diff -u -N --- src/liblogger/TLoggerLevelConfig.cpp (revision 0) +++ src/liblogger/TLoggerLevelConfig.cpp (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -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. +// ============================================================================ +#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; + } +} Index: src/common/TLoggerLevelConfig.cpp =================================================================== diff -u -N --- src/common/TLoggerLevelConfig.cpp (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/common/TLoggerLevelConfig.cpp (revision 0) @@ -1,33 +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 "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; - } -} Index: src/liblogger/TLoggerLevelConfig.h =================================================================== diff -u -N --- src/liblogger/TLoggerLevelConfig.h (revision 0) +++ src/liblogger/TLoggerLevelConfig.h (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,39 @@ +// ============================================================================ +// 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 Index: src/common/TLoggerLevelConfig.h =================================================================== diff -u -N --- src/common/TLoggerLevelConfig.h (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/common/TLoggerLevelConfig.h (revision 0) @@ -1,39 +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 __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 Index: src/liblogger/TLoggerLocationConfig.cpp =================================================================== diff -u -N --- src/liblogger/TLoggerLocationConfig.cpp (revision 0) +++ src/liblogger/TLoggerLocationConfig.cpp (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,32 @@ +// ============================================================================ +// 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 "TLoggerLocationConfig.h" + +namespace chcore +{ + TLoggerLocationConfig::TLoggerLocationConfig(const TSmartPath& pathLog) : m_pathLog(pathLog) + { + } + + chcore::TSmartPath TLoggerLocationConfig::GetLogPath() const + { + return m_pathLog; + } +} Index: src/common/TLoggerLocationConfig.cpp =================================================================== diff -u -N --- src/common/TLoggerLocationConfig.cpp (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/common/TLoggerLocationConfig.cpp (revision 0) @@ -1,32 +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 "TLoggerLocationConfig.h" - -namespace chcore -{ - TLoggerLocationConfig::TLoggerLocationConfig(const TSmartPath& pathLog) : m_pathLog(pathLog) - { - } - - chcore::TSmartPath TLoggerLocationConfig::GetLogPath() const - { - return m_pathLog; - } -} Index: src/liblogger/TLoggerLocationConfig.h =================================================================== diff -u -N --- src/liblogger/TLoggerLocationConfig.h (revision 0) +++ src/liblogger/TLoggerLocationConfig.h (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,40 @@ +// ============================================================================ +// 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 __TLOGGERLOCATIONCONFIG_H__ +#define __TLOGGERLOCATIONCONFIG_H__ + +#include "..\libchcore\TPath.h" + +namespace chcore +{ + class TLoggerLocationConfig + { + public: + TLoggerLocationConfig(const TSmartPath& pathLog); + + TSmartPath GetLogPath() const; + + private: + TSmartPath m_pathLog; + }; + + using TLoggerLocationConfigPtr = std::shared_ptr; +} + +#endif Index: src/common/TLoggerLocationConfig.h =================================================================== diff -u -N --- src/common/TLoggerLocationConfig.h (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/common/TLoggerLocationConfig.h (revision 0) @@ -1,40 +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 __TLOGGERLOCATIONCONFIG_H__ -#define __TLOGGERLOCATIONCONFIG_H__ - -#include "..\libchcore\TPath.h" - -namespace chcore -{ - class TLoggerLocationConfig - { - public: - TLoggerLocationConfig(const TSmartPath& pathLog); - - TSmartPath GetLogPath() const; - - private: - TSmartPath m_pathLog; - }; - - using TLoggerLocationConfigPtr = std::shared_ptr; -} - -#endif Index: src/liblogger/TMultiFileBackend.cpp =================================================================== diff -u -N --- src/liblogger/TMultiFileBackend.cpp (revision 0) +++ src/liblogger/TMultiFileBackend.cpp (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,95 @@ +// ============================================================================ +// 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/common/TMultiFileBackend.cpp =================================================================== diff -u -N --- src/common/TMultiFileBackend.cpp (revision 3f15d095b6b6692c9c9c469f979b9798f448b7c6) +++ src/common/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 0) +++ src/liblogger/TMultiFileBackend.h (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -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. +// ============================================================================ +#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/common/TMultiFileBackend.h =================================================================== diff -u -N --- src/common/TMultiFileBackend.h (revision 62d767936f1675e1db51174f53c91484fe691937) +++ src/common/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 --- src/liblogger/TMultiLoggerConfig.cpp (revision 0) +++ src/liblogger/TMultiLoggerConfig.cpp (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,43 @@ +// ============================================================================ +// Copyright (C) 2001-2016 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#include "stdafx.h" +#include "TMultiLoggerConfig.h" + +namespace chcore +{ + TLoggerLevelConfigPtr TMultiLoggerConfig::GetLoggerConfig(PCTSTR pszChannel, bool bForceAdd) + { + auto iterConfig = m_mapConfigs.find(pszChannel); + if (iterConfig == m_mapConfigs.end()) + { + if (bForceAdd) + 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) + { + TLoggerLevelConfigPtr spLoggerConfig = GetLoggerConfig(pszChannel, true); + spLoggerConfig->SetMinSeverityLevel(eLevel); + } +} Index: src/common/TMultiLoggerConfig.cpp =================================================================== diff -u -N --- src/common/TMultiLoggerConfig.cpp (revision b8b97b70743c49fcc2aee0db4cb7118db5e26dab) +++ src/common/TMultiLoggerConfig.cpp (revision 0) @@ -1,43 +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 "TMultiLoggerConfig.h" - -namespace chcore -{ - TLoggerLevelConfigPtr TMultiLoggerConfig::GetLoggerConfig(PCTSTR pszChannel, bool bForceAdd) - { - auto iterConfig = m_mapConfigs.find(pszChannel); - if (iterConfig == m_mapConfigs.end()) - { - if (bForceAdd) - 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) - { - TLoggerLevelConfigPtr spLoggerConfig = GetLoggerConfig(pszChannel, true); - spLoggerConfig->SetMinSeverityLevel(eLevel); - } -} Index: src/liblogger/TMultiLoggerConfig.h =================================================================== diff -u -N --- src/liblogger/TMultiLoggerConfig.h (revision 0) +++ src/liblogger/TMultiLoggerConfig.h (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,40 @@ +// ============================================================================ +// 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 __TMULTILOGGERCONFIG_H__ +#define __TMULTILOGGERCONFIG_H__ + +#include +#include "TLoggerLevelConfig.h" + +namespace chcore +{ + class TMultiLoggerConfig + { + public: + TLoggerLevelConfigPtr GetLoggerConfig(PCTSTR pszChannel, bool bForceAdd = false); + void SetLogLevel(PCTSTR pszChannel, boost::log::trivial::severity_level eLevel); + + private: + std::map m_mapConfigs; // channel, config + }; + + using TMultiLoggerConfigPtr = std::shared_ptr; +} + +#endif Index: src/common/TMultiLoggerConfig.h =================================================================== diff -u -N --- src/common/TMultiLoggerConfig.h (revision b8b97b70743c49fcc2aee0db4cb7118db5e26dab) +++ src/common/TMultiLoggerConfig.h (revision 0) @@ -1,40 +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 __TMULTILOGGERCONFIG_H__ -#define __TMULTILOGGERCONFIG_H__ - -#include -#include "TLoggerLevelConfig.h" - -namespace chcore -{ - class TMultiLoggerConfig - { - public: - TLoggerLevelConfigPtr GetLoggerConfig(PCTSTR pszChannel, bool bForceAdd = false); - void SetLogLevel(PCTSTR pszChannel, boost::log::trivial::severity_level eLevel); - - private: - std::map m_mapConfigs; // channel, config - }; - - using TMultiLoggerConfigPtr = std::shared_ptr; -} - -#endif Index: src/liblogger/liblogger.vc140.vcxproj =================================================================== diff -u -N --- src/liblogger/liblogger.vc140.vcxproj (revision 0) +++ src/liblogger/liblogger.vc140.vcxproj (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,495 @@ + + + + + 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 --- src/liblogger/liblogger.vc140.vcxproj.filters (revision 0) +++ src/liblogger/liblogger.vc140.vcxproj.filters (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,86 @@ + + + + + {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 + + + \ No newline at end of file Index: src/liblogger/stdafx.cpp =================================================================== diff -u -N --- src/liblogger/stdafx.cpp (revision 0) +++ src/liblogger/stdafx.cpp (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// libchcore.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file Index: src/liblogger/stdafx.h =================================================================== diff -u -N --- src/liblogger/stdafx.h (revision 0) +++ src/liblogger/stdafx.h (revision cca174e74e108de1f5729e4cc6c46d2b9a5e25a7) @@ -0,0 +1,15 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include "../common/targetver.h" + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files: +#include +#include +#include +#include