diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/LoggerI.cpp | 8 | ||||
-rw-r--r-- | cpp/src/Ice/LoggerI.h | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/cpp/src/Ice/LoggerI.cpp b/cpp/src/Ice/LoggerI.cpp index 720cd4d58a2..3fed27a131c 100644 --- a/cpp/src/Ice/LoggerI.cpp +++ b/cpp/src/Ice/LoggerI.cpp @@ -14,6 +14,8 @@ using namespace std; using namespace Ice; using namespace IceInternal; +IceUtil::Mutex Ice::LoggerI::_globalMutex; + Ice::LoggerI::LoggerI(const string& prefix) { if(!prefix.empty()) @@ -30,7 +32,7 @@ Ice::LoggerI::LoggerI(const string& prefix) void Ice::LoggerI::trace(const string& category, const string& message) { - IceUtil::Mutex::Lock sync(*this); + IceUtil::Mutex::Lock sync(_globalMutex); string s = "[ " + category + ": " + message + " ]"; string::size_type idx = 0; while((idx = s.find("\n", idx)) != string::npos) @@ -45,13 +47,13 @@ Ice::LoggerI::trace(const string& category, const string& message) void Ice::LoggerI::warning(const string& message) { - IceUtil::Mutex::Lock sync(*this); + IceUtil::Mutex::Lock sync(_globalMutex); cerr << _prefix << "warning: " << message << endl; } void Ice::LoggerI::error(const string& message) { - IceUtil::Mutex::Lock sync(*this); + IceUtil::Mutex::Lock sync(_globalMutex); cerr << _prefix << "error: " << message << endl; } diff --git a/cpp/src/Ice/LoggerI.h b/cpp/src/Ice/LoggerI.h index f7706247af5..23afb9597b9 100644 --- a/cpp/src/Ice/LoggerI.h +++ b/cpp/src/Ice/LoggerI.h @@ -17,7 +17,7 @@ namespace Ice { -class LoggerI : public Logger, public ::IceUtil::Mutex +class LoggerI : public Logger { public: LoggerI(const std::string&); @@ -30,6 +30,12 @@ private: std::string _prefix; std::string _emptyPrefix; + + // + // A global mutex is used to avoid garbled output with multiple + // communicators. + // + static IceUtil::Mutex _globalMutex; }; } |