summaryrefslogtreecommitdiff
path: root/log.cpp
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2010-10-08 07:01:44 +0300
committerGluzskiy Alexandr <sss123next@list.ru>2010-10-08 07:01:44 +0300
commitd5721b974a58ed5a26f33346dae728d93a7c1803 (patch)
tree2679ec39d8a44b5c3bdaf947d21881135460e7b7 /log.cpp
parent7df7cc0f3a8435c18e4491b04827deb47078b6d5 (diff)
boost threads and mutexes, better error handling (thread's timeouts)
Diffstat (limited to 'log.cpp')
-rw-r--r--log.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/log.cpp b/log.cpp
index 187ce85..d4d65a7 100644
--- a/log.cpp
+++ b/log.cpp
@@ -21,10 +21,12 @@ logtofile& logtofile::operator<<(TCHAR *buf)
extern bool bDebugLog;
if(bDebugLog)
{
+ log_mutex.lock();
char *tmp = mir_utf8encodeW(buf);
log.open(path, std::ios::app |std::ios::ate);
log<<tmp;
log.close();
+ log_mutex.unlock();
mir_free(tmp);
}
return *this;
@@ -34,10 +36,12 @@ logtofile& logtofile::operator<<(char *buf)
extern bool bDebugLog;
if(bDebugLog)
{
+ log_mutex.lock();
char *tmp = mir_utf8encode(buf);
log.open(path, std::ios::app |std::ios::ate);
log<<tmp;
log.close();
+ log_mutex.unlock();
mir_free(tmp);
}
return *this;
@@ -47,10 +51,12 @@ logtofile& logtofile::operator<<(string buf)
extern bool bDebugLog;
if(bDebugLog)
{
+ log_mutex.lock();
char *tmp = mir_utf8encode(buf.c_str());
log.open(path, std::ios::app |std::ios::ate);
log<<tmp;
log.close();
+ log_mutex.unlock();
mir_free(tmp);
}
return *this;
@@ -60,10 +66,12 @@ logtofile& logtofile::operator<<(wstring buf)
extern bool bDebugLog;
if(bDebugLog)
{
+ log_mutex.lock();
char *tmp = mir_utf8encodeW(buf.c_str());
log.open(path, std::ios::app |std::ios::ate);
log<<tmp;
log.close();
+ log_mutex.unlock();
mir_free(tmp);
}
return *this;