summaryrefslogtreecommitdiff
path: root/plugins/New_GPG/src/log.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/New_GPG/src/log.cpp')
-rwxr-xr-xplugins/New_GPG/src/log.cpp60
1 files changed, 32 insertions, 28 deletions
diff --git a/plugins/New_GPG/src/log.cpp b/plugins/New_GPG/src/log.cpp
index 598047b5c3..c5f704ec57 100755
--- a/plugins/New_GPG/src/log.cpp
+++ b/plugins/New_GPG/src/log.cpp
@@ -16,71 +16,75 @@
#include "stdafx.h"
-
logtofile& logtofile::operator<<(wchar_t *buf)
{
- if(_bDebugLog != globals.bDebugLog)
+ if (_bDebugLog != globals.bDebugLog)
init();
- log_mutex.lock();
- log.open(toUTF8(path).c_str(), std::ios::app |std::ios::ate);
- log<<toUTF8(buf);
- log<<"\n";
+
+ mir_cslock l(csLock);
+ log.open(toUTF8(path).c_str(), std::ios::app | std::ios::ate);
+ log << toUTF8(buf);
+ log << "\n";
log.close();
- log_mutex.unlock();
return *this;
}
+
logtofile& logtofile::operator<<(char *buf)
{
- if(_bDebugLog != globals.bDebugLog)
+ if (_bDebugLog != globals.bDebugLog)
init();
- log_mutex.lock();
- log.open(toUTF8(path).c_str(), std::ios::app |std::ios::ate);
- log<<buf;
- log<<"\n";
+
+ mir_cslock l(csLock);
+ log.open(toUTF8(path).c_str(), std::ios::app | std::ios::ate);
+ log << buf;
+ log << "\n";
log.close();
- log_mutex.unlock();
return *this;
}
+
logtofile& logtofile::operator<<(string buf)
{
- if(_bDebugLog != globals.bDebugLog)
+ if (_bDebugLog != globals.bDebugLog)
init();
- log_mutex.lock();
+
+ mir_cslock l(csLock);
char *tmp = mir_utf8encode(buf.c_str());
- log.open(toUTF8(path).c_str(), std::ios::app |std::ios::ate);
- log<<tmp;
- log<<"\n";
+ log.open(toUTF8(path).c_str(), std::ios::app | std::ios::ate);
+ log << tmp;
+ log << "\n";
log.close();
- log_mutex.unlock();
mir_free(tmp);
return *this;
}
+
logtofile& logtofile::operator<<(wstring buf)
{
- if(_bDebugLog != globals.bDebugLog)
+ if (_bDebugLog != globals.bDebugLog)
init();
- log_mutex.lock();
- log.open(toUTF8(path).c_str(), std::ios::app |std::ios::ate);
- log<<toUTF8(buf);
- log<<"\n";
+
+ mir_cslock l(csLock);
+ log.open(toUTF8(path).c_str(), std::ios::app | std::ios::ate);
+ log << toUTF8(buf);
+ log << "\n";
log.close();
- log_mutex.unlock();
return *this;
}
+
void logtofile::init()
{
- if(globals.bDebugLog)
- {
- if(path)
+ if (globals.bDebugLog) {
+ if (path)
mir_free(path);
path = UniGetContactSettingUtf(NULL, MODULENAME, "szLogFilePath", L"C:\\GPGdebug.log");
}
_bDebugLog = globals.bDebugLog;
}
+
logtofile::logtofile()
{
path = nullptr;
}
+
logtofile::~logtofile()
{
mir_free(path);