summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/LoggerI.cpp
diff options
context:
space:
mode:
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;
}