summaryrefslogtreecommitdiff
path: root/cppe/src/IceE/LoggerI.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2005-07-05 11:09:55 +0000
committerDwayne Boone <dwayne@zeroc.com>2005-07-05 11:09:55 +0000
commit9b8cc712d4a41d71840416776bc94ee8485bb9b3 (patch)
tree7d467fdd6a66bc2b5878d82070d45adbd5c20414 /cppe/src/IceE/LoggerI.cpp
parentcleaning the cache method out of ReferenceFactory (diff)
downloadice-9b8cc712d4a41d71840416776bc94ee8485bb9b3.tar.bz2
ice-9b8cc712d4a41d71840416776bc94ee8485bb9b3.tar.xz
ice-9b8cc712d4a41d71840416776bc94ee8485bb9b3.zip
Changed Ice to IceE EVERYWHERE!!!
Diffstat (limited to 'cppe/src/IceE/LoggerI.cpp')
-rw-r--r--cppe/src/IceE/LoggerI.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/cppe/src/IceE/LoggerI.cpp b/cppe/src/IceE/LoggerI.cpp
new file mode 100644
index 00000000000..4099dcb89de
--- /dev/null
+++ b/cppe/src/IceE/LoggerI.cpp
@@ -0,0 +1,82 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICEE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <IceE/Time.h>
+#include <IceE/LoggerI.h>
+
+using namespace std;
+using namespace IceE;
+using namespace IceEInternal;
+
+IceE::Mutex IceE::LoggerI::_globalMutex;
+
+IceE::LoggerI::LoggerI(const string& prefix, bool timestamp) :
+ _timestamp(timestamp)
+{
+ if(!prefix.empty())
+ {
+ _prefix = prefix + ": ";
+ }
+}
+
+void
+IceE::LoggerI::print(const string& message)
+{
+ IceE::Mutex::Lock sync(_globalMutex);
+
+ fprintf(stderr, "%s\n", message.c_str());
+}
+
+void
+IceE::LoggerI::trace(const string& category, const string& message)
+{
+ IceE::Mutex::Lock sync(_globalMutex);
+
+ string s = "[ ";
+ if(_timestamp)
+ {
+ s += IceE::Time::now().toString() + " ";
+ }
+ s += _prefix;
+ if(!category.empty())
+ {
+ s += category + ": ";
+ }
+ s += message + " ]";
+
+ string::size_type idx = 0;
+ while((idx = s.find("\n", idx)) != string::npos)
+ {
+ s.insert(idx + 1, " ");
+ ++idx;
+ }
+ fprintf(stderr, "%s\n", s.c_str());
+}
+
+void
+IceE::LoggerI::warning(const string& message)
+{
+ IceE::Mutex::Lock sync(_globalMutex);
+ if(_timestamp)
+ {
+ fprintf(stderr, "%s ", IceE::Time::now().toString().c_str());
+ }
+ fprintf(stderr, "%s warning: %s\n", _prefix.c_str(), message.c_str());
+}
+
+void
+IceE::LoggerI::error(const string& message)
+{
+ IceE::Mutex::Lock sync(_globalMutex);
+ if(_timestamp)
+ {
+ fprintf(stderr, "%s ", IceE::Time::now().toString().c_str());
+ }
+ fprintf(stderr, "%s error: %s\n", _prefix.c_str(), message.c_str());
+}