summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2002-07-31 16:01:26 +0000
committerMatthew Newhook <matthew@zeroc.com>2002-07-31 16:01:26 +0000
commitc1507126f37cd7046ebc60bf1239d92a7ce0c27b (patch)
tree0df37f986204f2422dc9953cf3404baeb3c89785 /cpp/src
parentImproved diagnostics for empty enumerations. (diff)
downloadice-c1507126f37cd7046ebc60bf1239d92a7ce0c27b.tar.bz2
ice-c1507126f37cd7046ebc60bf1239d92a7ce0c27b.tar.xz
ice-c1507126f37cd7046ebc60bf1239d92a7ce0c27b.zip
Logger is now globally mutex protected.
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/LoggerI.cpp8
-rw-r--r--cpp/src/Ice/LoggerI.h8
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;
};
}