aboutsummaryrefslogtreecommitdiffstats
path: root/CommonLibs/Logger.cpp
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-07-01 20:13:32 +0200
committerpespin <pespin@sysmocom.de>2019-07-19 11:44:13 +0000
commitc9202ab0be5e3e89f5fa4236ef45d550cee91af6 (patch)
tree85e790a6fdf5db260eceabdb463a714cc30a1b8a /CommonLibs/Logger.cpp
parentb49a42e70b65d71ce705be931ddcfe88109da8d8 (diff)
Logger: global Log mutex is now available from C code
This way the C++ logging API can still be used while allowing for C files to use the same mutex. Change-Id: I473e57479f8ae98a84ad00b76ff338f79f732236
Diffstat (limited to 'CommonLibs/Logger.cpp')
-rw-r--r--CommonLibs/Logger.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/CommonLibs/Logger.cpp b/CommonLibs/Logger.cpp
index 171c635..f68fab5 100644
--- a/CommonLibs/Logger.cpp
+++ b/CommonLibs/Logger.cpp
@@ -35,8 +35,6 @@
using namespace std;
-Mutex gLogToLock;
-
std::ostream& operator<<(std::ostream& os, std::ostringstream& ss)
{
return os << ss.str();
@@ -45,15 +43,13 @@ std::ostream& operator<<(std::ostream& os, std::ostringstream& ss)
Log::~Log()
{
int old_state;
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state);
int mlen = mStream.str().size();
int neednl = (mlen==0 || mStream.str()[mlen-1] != '\n');
const char *fmt = neednl ? "%s\n" : "%s";
- ScopedLock lock(gLogToLock);
- // The COUT() macro prevents messages from stomping each other but adds uninteresting thread numbers,
- // so just use std::cout.
+
+ log_mutex_lock_canceldisable(&old_state);
LOGPSRC(mCategory, mPriority, filename, line, fmt, mStream.str().c_str());
- pthread_setcancelstate(old_state, NULL);
+ log_mutex_unlock_canceldisable(old_state);
}
ostringstream& Log::get()