From f7d2c07c102d940727b0f053864c04ed32a76ff8 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Sat, 13 Oct 2012 09:49:24 +0000 Subject: Quotes: folders restructurization git-svn-id: http://svn.miranda-ng.org/main/trunk@1905 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Quotes/src/Log.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 protocols/Quotes/src/Log.cpp (limited to 'protocols/Quotes/src/Log.cpp') diff --git a/protocols/Quotes/src/Log.cpp b/protocols/Quotes/src/Log.cpp new file mode 100644 index 0000000000..d692763bad --- /dev/null +++ b/protocols/Quotes/src/Log.cpp @@ -0,0 +1,56 @@ +#include "StdAfx.h" +#include "Log.h" +#include "LightMutex.h" +#include "EconomicRateInfo.h" +#include "CreateFilePath.h" + +namespace +{ + CLightMutex g_Mutex; + + tstring get_log_file_name() + { + return CreateFilePath(_T("Quotes.log")); + } + + bool is_log_enabled() + { +#ifdef _DEBUG + return true; +#else + return (1 == DBGetContactSettingByte(NULL,QUOTES_PROTOCOL_NAME,DB_STR_ENABLE_LOG,false)); +#endif + } + + void do_log(const tstring& rsFileName,ESeverity nSeverity,const tstring& rsMsg) + { + CGuard guard(g_Mutex); + tofstream file(rsFileName.c_str(),std::ios::ate|std::ios::app); + if(file.good()) + { + TCHAR szTime[20]; +// TCHAR sz[10000+1]; + _tstrtime_s(szTime); + file << szTime << _T(" ================================>\n") << rsMsg << _T("\n\n"); + +// size_t cBytes = rsMsg.size(); +// const TCHAR* p = rsMsg.c_str(); +// for(size_t c = 0;c < cBytes;c += 10000,p+=10000) +// { +// _tcsncpy_s(sz,p,10000); +// file << sz; +// } +// +// file << "\n\n"; + } + } +} + +void LogIt(ESeverity nSeverity,const tstring& rsMsg) +{ + if(is_log_enabled()) + { + tstring sFileName = get_log_file_name(); + do_log(sFileName,nSeverity,rsMsg); + } +} -- cgit v1.2.3