summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/LoggerI.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2006-12-19 19:44:44 +0000
committerDwayne Boone <dwayne@zeroc.com>2006-12-19 19:44:44 +0000
commit50cb4237b08e7519c2b848ee2479df965dfd148a (patch)
tree04cf9e0a40b68cfc9429532961ba11b12dc3950d /cpp/src/Ice/LoggerI.cpp
parenttypo (diff)
downloadice-50cb4237b08e7519c2b848ee2479df965dfd148a.tar.bz2
ice-50cb4237b08e7519c2b848ee2479df965dfd148a.tar.xz
ice-50cb4237b08e7519c2b848ee2479df965dfd148a.zip
Added Ice.Logger.DateFormat property
Diffstat (limited to 'cpp/src/Ice/LoggerI.cpp')
-rw-r--r--cpp/src/Ice/LoggerI.cpp40
1 files changed, 34 insertions, 6 deletions
diff --git a/cpp/src/Ice/LoggerI.cpp b/cpp/src/Ice/LoggerI.cpp
index dc09fbf956e..cd83067a25f 100644
--- a/cpp/src/Ice/LoggerI.cpp
+++ b/cpp/src/Ice/LoggerI.cpp
@@ -17,12 +17,18 @@ using namespace IceInternal;
static IceUtil::StaticMutex outputMutex = ICE_STATIC_MUTEX_INITIALIZER;
-Ice::LoggerI::LoggerI(const string& prefix)
+Ice::LoggerI::LoggerI(const string& prefix, const string& dateFormat) :
+ _dateFormat(dateFormat)
{
if(!prefix.empty())
{
_prefix = prefix + ": ";
}
+
+ if(_dateFormat == "0")
+ {
+ _dateFormat = "";
+ }
}
void
@@ -36,9 +42,12 @@ Ice::LoggerI::print(const string& message)
void
Ice::LoggerI::trace(const string& category, const string& message)
{
- IceUtil::StaticMutex::Lock sync(outputMutex);
-
- string s = "[ " + IceUtil::Time::now().toDateTime() + " " + _prefix;
+ string s = "[ ";
+ if(!_dateFormat.empty())
+ {
+ s += IceUtil::Time::now().toDateTime(_dateFormat) + " ";
+ }
+ s += _prefix;
if(!category.empty())
{
s += category + ": ";
@@ -51,19 +60,38 @@ Ice::LoggerI::trace(const string& category, const string& message)
s.insert(idx + 1, " ");
++idx;
}
+
+ IceUtil::StaticMutex::Lock sync(outputMutex);
+
cerr << s << endl;
}
void
Ice::LoggerI::warning(const string& message)
{
+ string s;
+ if(!_dateFormat.empty())
+ {
+ s += IceUtil::Time::now().toDateTime(_dateFormat) + " ";
+ }
+ s += _prefix + "warning: " + message;
+
IceUtil::StaticMutex::Lock sync(outputMutex);
- cerr << IceUtil::Time::now().toDateTime() << " " << _prefix << "warning: " << message << endl;
+
+ cerr << s << endl;
}
void
Ice::LoggerI::error(const string& message)
{
+ string s;
+ if(!_dateFormat.empty())
+ {
+ s += IceUtil::Time::now().toDateTime(_dateFormat) + " ";
+ }
+ s += _prefix + "error: " + message;
+
IceUtil::StaticMutex::Lock sync(outputMutex);
- cerr << IceUtil::Time::now().toDateTime() << " " << _prefix << "error: " << message << endl;
+
+ cerr << s << endl;
}