summaryrefslogtreecommitdiff
path: root/plugins/CurrencyRates/src/Log.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/CurrencyRates/src/Log.cpp')
-rw-r--r--plugins/CurrencyRates/src/Log.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/plugins/CurrencyRates/src/Log.cpp b/plugins/CurrencyRates/src/Log.cpp
new file mode 100644
index 0000000000..fcfb0adc35
--- /dev/null
+++ b/plugins/CurrencyRates/src/Log.cpp
@@ -0,0 +1,41 @@
+#include "StdAfx.h"
+
+namespace
+{
+ mir_cs g_Mutex;
+
+ tstring get_log_file_name()
+ {
+ return CreateFilePath(L"Quotes.log");
+ }
+
+ bool is_log_enabled()
+ {
+#ifdef _DEBUG
+ return true;
+#else
+ return (1 == db_get_b(NULL, QUOTES_PROTOCOL_NAME, DB_STR_ENABLE_LOG, false));
+#endif
+ }
+
+ void do_log(const tstring& rsFileName, const tstring& rsMsg)
+ {
+ mir_cslock lck(g_Mutex);
+ tofstream file(rsFileName.c_str(), std::ios::ate | std::ios::app);
+ if (file.good())
+ {
+ wchar_t szTime[20];
+ _tstrtime_s(szTime);
+ file << szTime << L" ================================>\n" << rsMsg << L"\n\n";
+ }
+ }
+}
+
+void LogIt(const tstring& rsMsg)
+{
+ if (is_log_enabled())
+ {
+ tstring sFileName = get_log_file_name();
+ do_log(sFileName, rsMsg);
+ }
+}