diff options
author | Benoit Foucher <benoit@zeroc.com> | 2003-03-06 20:14:35 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2003-03-06 20:14:35 +0000 |
commit | 40a2e5677daadbf4fafd6111de6040163ee42869 (patch) | |
tree | acef4a4aa9896b3f04186274c44e6d6c454fb8ea /cpp/src/Ice/LoggerI.cpp | |
parent | Fixed bug caused by a redundant check for encapsulation version that left (diff) | |
download | ice-40a2e5677daadbf4fafd6111de6040163ee42869.tar.bz2 ice-40a2e5677daadbf4fafd6111de6040163ee42869.tar.xz ice-40a2e5677daadbf4fafd6111de6040163ee42869.zip |
Added IceUtil::Time::toString() and support for timestamps in the default
logger.
Diffstat (limited to 'cpp/src/Ice/LoggerI.cpp')
-rw-r--r-- | cpp/src/Ice/LoggerI.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/cpp/src/Ice/LoggerI.cpp b/cpp/src/Ice/LoggerI.cpp index 269851c8d6f..2bafc2675a6 100644 --- a/cpp/src/Ice/LoggerI.cpp +++ b/cpp/src/Ice/LoggerI.cpp @@ -12,6 +12,7 @@ // // ********************************************************************** +#include <IceUtil/Time.h> #include <Ice/LoggerI.h> using namespace std; @@ -20,7 +21,8 @@ using namespace IceInternal; IceUtil::Mutex Ice::LoggerI::_globalMutex; -Ice::LoggerI::LoggerI(const string& prefix) +Ice::LoggerI::LoggerI(const string& prefix, bool timestamp) : + _timestamp(timestamp) { if(!prefix.empty()) { @@ -32,7 +34,14 @@ void Ice::LoggerI::trace(const string& category, const string& message) { IceUtil::Mutex::Lock sync(_globalMutex); - string s = "[ " + _prefix + category + ": " + message + " ]"; + + string s = "[ "; + if(_timestamp) + { + s += IceUtil::Time::now().toString() + " "; + } + s += _prefix + category + ": " + message + " ]"; + string::size_type idx = 0; while((idx = s.find("\n", idx)) != string::npos) { @@ -46,12 +55,20 @@ void Ice::LoggerI::warning(const string& message) { IceUtil::Mutex::Lock sync(_globalMutex); - cerr << _prefix << "warning: " << message << endl; + if(_timestamp) + { + cerr << IceUtil::Time::now().toString() << " "; + } + cerr << _prefix << "warning: " << message << endl; } void Ice::LoggerI::error(const string& message) { IceUtil::Mutex::Lock sync(_globalMutex); - cerr << _prefix << "error: " << message << endl; + if(_timestamp) + { + cerr << IceUtil::Time::now().toString() << " "; + } + cerr << _prefix << "error: " << message << endl; } |