Index: src/libchcore/TTask.cpp =================================================================== diff -u -r12b36349f6214befeace08efa9acc7e03be0d847 -r7de00e54431d78b6c54fad6fb163dbc306381ef5 --- src/libchcore/TTask.cpp (.../TTask.cpp) (revision 12b36349f6214befeace08efa9acc7e03be0d847) +++ src/libchcore/TTask.cpp (.../TTask.cpp) (revision 7de00e54431d78b6c54fad6fb163dbc306381ef5) @@ -690,30 +690,12 @@ void TTask::OnBeginOperation() { - CTime tm = CTime::GetCurrentTime(); - - TString strFormat = _T("\r\n# COPYING THREAD STARTED #\r\nBegan processing data (dd:mm:yyyy) %day.%month.%year at %hour:%minute.%second"); - strFormat.Replace(_T("%year"), boost::lexical_cast(tm.GetYear()).c_str()); - strFormat.Replace(_T("%month"), boost::lexical_cast(tm.GetMonth()).c_str()); - strFormat.Replace(_T("%day"), boost::lexical_cast(tm.GetDay()).c_str()); - strFormat.Replace(_T("%hour"), boost::lexical_cast(tm.GetHour()).c_str()); - strFormat.Replace(_T("%minute"), boost::lexical_cast(tm.GetMinute()).c_str()); - strFormat.Replace(_T("%second"), boost::lexical_cast(tm.GetSecond()).c_str()); - LOG_INFO(m_spLog) << strFormat.c_str(); + LOG_INFO(m_spLog) << _T("Processing thread started"); } void TTask::OnEndOperation() { - CTime tm = CTime::GetCurrentTime(); - - TString strFormat = _T("Finished processing data (dd:mm:yyyy) %day.%month.%year at %hour:%minute.%second"); - strFormat.Replace(_T("%year"), boost::lexical_cast(tm.GetYear()).c_str()); - strFormat.Replace(_T("%month"), boost::lexical_cast(tm.GetMonth()).c_str()); - strFormat.Replace(_T("%day"), boost::lexical_cast(tm.GetDay()).c_str()); - strFormat.Replace(_T("%hour"), boost::lexical_cast(tm.GetHour()).c_str()); - strFormat.Replace(_T("%minute"), boost::lexical_cast(tm.GetMinute()).c_str()); - strFormat.Replace(_T("%second"), boost::lexical_cast(tm.GetSecond()).c_str()); - LOG_INFO(m_spLog) << strFormat.c_str(); + LOG_INFO(m_spLog) << _T("Finished processing data"); } void TTask::RequestStopThread() Index: src/liblogger/TAsyncMultiLogger.h =================================================================== diff -u -r8f634460db3f225ca24f2e447b3730d4f0614166 -r7de00e54431d78b6c54fad6fb163dbc306381ef5 --- src/liblogger/TAsyncMultiLogger.h (.../TAsyncMultiLogger.h) (revision 8f634460db3f225ca24f2e447b3730d4f0614166) +++ src/liblogger/TAsyncMultiLogger.h (.../TAsyncMultiLogger.h) (revision 7de00e54431d78b6c54fad6fb163dbc306381ef5) @@ -23,14 +23,15 @@ #include #include #include "TLoggerRotationInfo.h" +#include "liblogger.h" namespace logger { class TAsyncMultiLogger; using TAsyncMultiLoggerPtr = std::shared_ptr; - class TAsyncMultiLogger + class LIBLOGGER_API TAsyncMultiLogger { public: static TAsyncMultiLoggerPtr GetInstance(); @@ -48,13 +49,16 @@ void LoggingThread(); private: +#pragma warning(push) +#pragma warning(disable: 4251) std::unordered_set m_setLoggerData; boost::shared_mutex m_mutex; std::shared_ptr m_spStopEvent; std::unique_ptr m_spThread; TLoggerRotationInfoPtr m_spGlobalRotationInfo; +#pragma warning(pop) }; } Fisheye: Tag 7de00e54431d78b6c54fad6fb163dbc306381ef5 refers to a dead (removed) revision in file `src/liblogger/TDateTimeFormatter.cpp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 7de00e54431d78b6c54fad6fb163dbc306381ef5 refers to a dead (removed) revision in file `src/liblogger/TDateTimeFormatter.h'. Fisheye: No comparison available. Pass `N' to diff? Index: src/liblogger/TLogFile.h =================================================================== diff -u -r12b36349f6214befeace08efa9acc7e03be0d847 -r7de00e54431d78b6c54fad6fb163dbc306381ef5 --- src/liblogger/TLogFile.h (.../TLogFile.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) +++ src/liblogger/TLogFile.h (.../TLogFile.h) (revision 7de00e54431d78b6c54fad6fb163dbc306381ef5) @@ -42,10 +42,10 @@ private: HANDLE GetFileHandle(); unsigned long long GetCurrentLogSize(); - void RotateFile(); + void RotateFile(); void RemoveObsoleteRotatedLogs(); - void ScanForRotatedLogs(); - bool NeedRotation(size_t stDataSize); + void ScanForRotatedLogs(); + bool NeedRotation(size_t stDataSize); private: std::wstring m_strLogPath; Index: src/liblogger/TLogFileData.h =================================================================== diff -u -r8f634460db3f225ca24f2e447b3730d4f0614166 -r7de00e54431d78b6c54fad6fb163dbc306381ef5 --- src/liblogger/TLogFileData.h (.../TLogFileData.h) (revision 8f634460db3f225ca24f2e447b3730d4f0614166) +++ src/liblogger/TLogFileData.h (.../TLogFileData.h) (revision 7de00e54431d78b6c54fad6fb163dbc306381ef5) @@ -24,10 +24,11 @@ #include #include "TLogFile.h" #include "TMultiLoggerConfig.h" +#include "liblogger.h" namespace logger { - class TLogFileData + class LIBLOGGER_API TLogFileData { public: TLogFileData(PCTSTR pszLogPath, const TMultiLoggerConfigPtr& spLoggerConfig, const TLoggerRotationInfoPtr& spRotationInfo); @@ -42,6 +43,8 @@ void CloseUnusedFile(); private: +#pragma warning(push) +#pragma warning(disable: 4251) std::list m_listEntries; boost::shared_mutex m_mutex; @@ -50,6 +53,7 @@ TMultiLoggerConfigPtr m_spLoggerConfig; TLogFile m_logFile; +#pragma warning(pop) friend class TLogRecord; friend class TAsyncMultiLogger; Index: src/liblogger/TLogRecord.h =================================================================== diff -u -r8f634460db3f225ca24f2e447b3730d4f0614166 -r7de00e54431d78b6c54fad6fb163dbc306381ef5 --- src/liblogger/TLogRecord.h (.../TLogRecord.h) (revision 8f634460db3f225ca24f2e447b3730d4f0614166) +++ src/liblogger/TLogRecord.h (.../TLogRecord.h) (revision 7de00e54431d78b6c54fad6fb163dbc306381ef5) @@ -21,16 +21,15 @@ #include #include "TLogFileData.h" -#include -#include "TDateTimeFormatter.h" +#include +#include namespace logger { - // do not export! class TLogRecord : public std::wstringstream { public: - TLogRecord(const TLogFileDataPtr& spFileData, ESeverityLevel eLevel); + TLogRecord(const TLogFileDataPtr& spFileData, ESeverityLevel eLevel, const std::wstring& wstrChannel); TLogRecord(const TLogRecord&) = delete; TLogRecord(TLogRecord&& rSrc); @@ -53,10 +52,13 @@ { } - inline TLogRecord::TLogRecord(const TLogFileDataPtr& spFileData, ESeverityLevel eLevel) : + inline TLogRecord::TLogRecord(const TLogFileDataPtr& spFileData, ESeverityLevel eLevel, const std::wstring& wstrChannel) : m_spFileData(spFileData) { - *this << TDateTimeFormatter::GetCurrentTime() << L" " << SeverityLevelToString(eLevel) << L" "; + boost::posix_time::wtime_facet* facet = new boost::posix_time::wtime_facet(); + facet->format(L"%Y-%m-%d %H:%M:%S.%f"); + imbue(std::locale(std::locale::classic(), facet)); + *this << boost::posix_time::microsec_clock::local_time() << L" [" << SeverityLevelToString(eLevel) << L"] " << wstrChannel << L": "; } inline TLogRecord::~TLogRecord() @@ -76,4 +78,13 @@ } } +#ifdef _MFC_VER + +inline std::wostream& operator<<(std::wostream &os, const CString& str) +{ + return os << (PCTSTR)str; +} + #endif + +#endif Fisheye: Tag 7de00e54431d78b6c54fad6fb163dbc306381ef5 refers to a dead (removed) revision in file `src/liblogger/TLogger.cpp'. Fisheye: No comparison available. Pass `N' to diff? Index: src/liblogger/TLogger.h =================================================================== diff -u -r8f634460db3f225ca24f2e447b3730d4f0614166 -r7de00e54431d78b6c54fad6fb163dbc306381ef5 --- src/liblogger/TLogger.h (.../TLogger.h) (revision 8f634460db3f225ca24f2e447b3730d4f0614166) +++ src/liblogger/TLogger.h (.../TLogger.h) (revision 7de00e54431d78b6c54fad6fb163dbc306381ef5) @@ -28,7 +28,6 @@ namespace logger { - // do not export class TLogger { public: @@ -46,13 +45,36 @@ friend class TLoggerFactory; }; + inline TLogger::TLogger(const TLogFileDataPtr& spFileData, PCTSTR pszChannel) : + m_spFileData(spFileData), + m_spLoggerConfig(spFileData->GetMultiLoggerConfig()->GetLoggerConfig(pszChannel)), + m_strChannel(pszChannel) + { + if(!spFileData) + throw std::invalid_argument("spFileData"); + } + + inline TLogFileDataPtr TLogger::GetLogFileData() const + { + return m_spFileData; + } + + inline ESeverityLevel TLogger::GetMinSeverity() const + { + return m_spLoggerConfig->GetMinSeverityLevel(); + } + + inline TLogRecord TLogger::OpenLogRecord(ESeverityLevel eLevel) const + { + return TLogRecord(m_spFileData, eLevel, m_strChannel); + } + using TLoggerPtr = std::unique_ptr; inline TLoggerPtr MakeLogger(const TLogFileDataPtr& spFileData, PCTSTR pszChannel) { return std::make_unique(spFileData, pszChannel); } - } #define LOG(log, level) for(logger::TLogRecord rec = (log)->OpenLogRecord(level); rec.IsEnabled(); rec.Disable()) rec Index: src/liblogger/TLoggerLevelConfig.h =================================================================== diff -u -r8f634460db3f225ca24f2e447b3730d4f0614166 -r7de00e54431d78b6c54fad6fb163dbc306381ef5 --- src/liblogger/TLoggerLevelConfig.h (.../TLoggerLevelConfig.h) (revision 8f634460db3f225ca24f2e447b3730d4f0614166) +++ src/liblogger/TLoggerLevelConfig.h (.../TLoggerLevelConfig.h) (revision 7de00e54431d78b6c54fad6fb163dbc306381ef5) @@ -21,10 +21,11 @@ #include "SeverityLevels.h" #include +#include "liblogger.h" namespace logger { - class TLoggerLevelConfig + class LIBLOGGER_API TLoggerLevelConfig { public: TLoggerLevelConfig(ESeverityLevel eMinSeverity = trace); Index: src/liblogger/TLoggerRotationInfo.h =================================================================== diff -u -r8f634460db3f225ca24f2e447b3730d4f0614166 -r7de00e54431d78b6c54fad6fb163dbc306381ef5 --- src/liblogger/TLoggerRotationInfo.h (.../TLoggerRotationInfo.h) (revision 8f634460db3f225ca24f2e447b3730d4f0614166) +++ src/liblogger/TLoggerRotationInfo.h (.../TLoggerRotationInfo.h) (revision 7de00e54431d78b6c54fad6fb163dbc306381ef5) @@ -20,10 +20,11 @@ #define __TLOGGERROTATIONINFO_H__ #include +#include "liblogger.h" namespace logger { - class TLoggerRotationInfo + class LIBLOGGER_API TLoggerRotationInfo { public: static const unsigned int DefaultMaxLogSize = 10 * 1024 * 1024; Index: src/liblogger/TMultiLoggerConfig.h =================================================================== diff -u -r12b36349f6214befeace08efa9acc7e03be0d847 -r7de00e54431d78b6c54fad6fb163dbc306381ef5 --- src/liblogger/TMultiLoggerConfig.h (.../TMultiLoggerConfig.h) (revision 12b36349f6214befeace08efa9acc7e03be0d847) +++ src/liblogger/TMultiLoggerConfig.h (.../TMultiLoggerConfig.h) (revision 7de00e54431d78b6c54fad6fb163dbc306381ef5) @@ -26,7 +26,7 @@ namespace logger { - class TMultiLoggerConfig + class LIBLOGGER_API TMultiLoggerConfig { public: TLoggerLevelConfigPtr GetLoggerConfig(PCTSTR pszChannel, bool bForceAdd = false); @@ -36,8 +36,11 @@ TLoggerLevelConfigPtr GetLoggerConfig(boost::upgrade_lock& lock, PCTSTR pszChannel, bool bForceAdd); private: +#pragma warning(push) +#pragma warning(disable: 4251) std::map m_mapConfigs; // channel, config boost::shared_mutex m_mutex; +#pragma warning(pop) }; using TMultiLoggerConfigPtr = std::shared_ptr; Index: src/liblogger/dllmain.cpp =================================================================== diff -u --- src/liblogger/dllmain.cpp (revision 0) +++ src/liblogger/dllmain.cpp (revision 7de00e54431d78b6c54fad6fb163dbc306381ef5) @@ -0,0 +1,16 @@ +// dllmain.cpp : Defines the entry point for the DLL application. +#include "stdafx.h" + +BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ulReasonForCall, LPVOID /*lpReserved*/) +{ + switch (ulReasonForCall) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + Index: src/liblogger/liblogger.cpp =================================================================== diff -u --- src/liblogger/liblogger.cpp (revision 0) +++ src/liblogger/liblogger.cpp (revision 7de00e54431d78b6c54fad6fb163dbc306381ef5) @@ -0,0 +1,5 @@ +// libchcore.cpp : Defines the exported functions for the DLL application. +// + +#include "stdafx.h" +#include "liblogger.h" Index: src/liblogger/liblogger.h =================================================================== diff -u --- src/liblogger/liblogger.h (revision 0) +++ src/liblogger/liblogger.h (revision 7de00e54431d78b6c54fad6fb163dbc306381ef5) @@ -0,0 +1,21 @@ +// The following ifdef block is the standard way of creating macros which make exporting +// from a DLL simpler. All files within this DLL are compiled with the LIBLOGGER_EXPORTS +// symbol defined on the command line. this symbol should not be defined on any project +// that uses this DLL. This way any other project whose source files include this file see +// LIBLOGGER_API functions as being imported from a DLL, whereas this DLL sees symbols +// defined with this macro as being exported. +#if defined(_WIN32) || defined(_WIN64) + #ifdef LIBLOGGER_EXPORTS + #define LIBLOGGER_API __declspec(dllexport) + #else + #define LIBLOGGER_API __declspec(dllimport) + #endif +#else + /** \brief Import/export macros + * + * These macros are being used throughout the whole code. They are meant to + * export symbols (if the LIBLOGGER_EXPORTS is defined) from this library + * (also for importing (when LIBLOGGER_EXPORTS macro is undefined) in other apps). + */ + #define LIBLOGGER_API +#endif Index: src/liblogger/liblogger.vc140.vcxproj =================================================================== diff -u -r12b36349f6214befeace08efa9acc7e03be0d847 -r7de00e54431d78b6c54fad6fb163dbc306381ef5 --- src/liblogger/liblogger.vc140.vcxproj (.../liblogger.vc140.vcxproj) (revision 12b36349f6214befeace08efa9acc7e03be0d847) +++ src/liblogger/liblogger.vc140.vcxproj (.../liblogger.vc140.vcxproj) (revision 7de00e54431d78b6c54fad6fb163dbc306381ef5) @@ -42,46 +42,46 @@ - StaticLibrary + DynamicLibrary v120_xp Unicode true - StaticLibrary + DynamicLibrary v120_xp Unicode true - StaticLibrary + DynamicLibrary v120_xp Unicode - StaticLibrary + DynamicLibrary v120_xp Unicode - StaticLibrary + DynamicLibrary Unicode true v120_xp - StaticLibrary + DynamicLibrary Unicode true v120_xp - StaticLibrary + DynamicLibrary Unicode v120_xp - StaticLibrary + DynamicLibrary Unicode v120_xp @@ -179,7 +179,7 @@ Disabled - _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;%(PreprocessorDefinitions) + _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 @@ -203,7 +203,7 @@ Disabled - _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;TESTING;%(PreprocessorDefinitions) + _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 @@ -247,7 +247,7 @@ Disabled - _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;%(PreprocessorDefinitions) + _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 @@ -274,7 +274,7 @@ Disabled - _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;TESTING;%(PreprocessorDefinitions) + _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 @@ -316,7 +316,7 @@ MaxSpeed true - _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;%(PreprocessorDefinitions) + _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 @@ -342,7 +342,7 @@ 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) + _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 @@ -388,7 +388,7 @@ MaxSpeed true - _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;liblogger_EXPORTS;_BIND_TO_CURRENT_VCLIBS_VERSION=1;NOMINMAX;%(PreprocessorDefinitions) + _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 @@ -416,7 +416,7 @@ 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) + _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 @@ -455,7 +455,7 @@ - + @@ -468,6 +468,8 @@ + + Create Create @@ -479,10 +481,8 @@ Create - - Index: src/liblogger/liblogger.vc140.vcxproj.filters =================================================================== diff -u -r12b36349f6214befeace08efa9acc7e03be0d847 -r7de00e54431d78b6c54fad6fb163dbc306381ef5 --- src/liblogger/liblogger.vc140.vcxproj.filters (.../liblogger.vc140.vcxproj.filters) (revision 12b36349f6214befeace08efa9acc7e03be0d847) +++ src/liblogger/liblogger.vc140.vcxproj.filters (.../liblogger.vc140.vcxproj.filters) (revision 7de00e54431d78b6c54fad6fb163dbc306381ef5) @@ -12,9 +12,6 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - {eb9df11f-3ddf-4f04-bc60-920c9bec2694} - @@ -47,8 +44,8 @@ Source Files - - Source Files\Utils + + Source Files\Library files @@ -58,9 +55,6 @@ Source Files - - Source Files - Source Files @@ -76,8 +70,11 @@ Source Files - - Source Files\Utils + + Source Files\Library files + + Source Files\Library files + \ No newline at end of file