diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2006-12-19 19:44:44 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2006-12-19 19:44:44 +0000 |
commit | 50cb4237b08e7519c2b848ee2479df965dfd148a (patch) | |
tree | 04cf9e0a40b68cfc9429532961ba11b12dc3950d /cpp/src | |
parent | typo (diff) | |
download | ice-50cb4237b08e7519c2b848ee2479df965dfd148a.tar.bz2 ice-50cb4237b08e7519c2b848ee2479df965dfd148a.tar.xz ice-50cb4237b08e7519c2b848ee2479df965dfd148a.zip |
Added Ice.Logger.DateFormat property
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/Instance.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/LoggerI.cpp | 40 | ||||
-rw-r--r-- | cpp/src/Ice/LoggerI.h | 4 | ||||
-rw-r--r-- | cpp/src/Ice/PropertyNames.cpp | 5 | ||||
-rw-r--r-- | cpp/src/Ice/PropertyNames.h | 2 | ||||
-rw-r--r-- | cpp/src/IceUtil/Time.cpp | 4 |
6 files changed, 45 insertions, 14 deletions
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index 8cf07bdf2e4..db14bc47ca0 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -592,7 +592,9 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi #endif else { - _initData.logger = new LoggerI(_initData.properties->getProperty("Ice.ProgramName")); + _initData.logger = + new LoggerI(_initData.properties->getProperty("Ice.ProgramName"), + _initData.properties->getPropertyWithDefault("Ice.Logger.DateFormat", "%x %H:%M:%S")); } } 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; } diff --git a/cpp/src/Ice/LoggerI.h b/cpp/src/Ice/LoggerI.h index 513b0b744ad..503f1f0498a 100644 --- a/cpp/src/Ice/LoggerI.h +++ b/cpp/src/Ice/LoggerI.h @@ -19,7 +19,7 @@ class LoggerI : public Logger { public: - LoggerI(const std::string&); + LoggerI(const std::string&, const std::string&); virtual void print(const std::string&); virtual void trace(const std::string&, const std::string&); @@ -29,7 +29,7 @@ public: private: std::string _prefix; - std::string _emptyPrefix; + std::string _dateFormat; }; } diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp index 6e84d41e3a4..689abfb4e7b 100644 --- a/cpp/src/Ice/PropertyNames.cpp +++ b/cpp/src/Ice/PropertyNames.cpp @@ -7,7 +7,7 @@ // // ********************************************************************** -// Generated by makeprops.py from file `../config/PropertyNames.def', Mon Dec 18 13:40:21 2006 +// Generated by makeprops.py from file `./config/PropertyNames.def', Tue Dec 19 14:18:06 2006 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -17,6 +17,7 @@ const char* IceInternal::PropertyNames::IceProps[] = { "Ice.ACM.Client", "Ice.ACM.Server", + "Ice.AllowableEndpoints", "Ice.ChangeUser", "Ice.Compression.Level", "Ice.Config", @@ -45,6 +46,7 @@ const char* IceInternal::PropertyNames::IceProps[] = "Ice.GC.Interval", "Ice.ImplicitContext", "Ice.InitPlugins", + "Ice.Logger.DateFormat", "Ice.LoggerPlugin", "Ice.MessageSizeMax", "Ice.MonitorConnections", @@ -101,7 +103,6 @@ const char* IceInternal::PropertyNames::IceProps[] = "Ice.Warn.Datagrams", "Ice.Warn.Dispatch", "Ice.Warn.Endpoints", - "Ice.AllowableEndpoints", 0 }; diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h index c1bdfae9cbc..048378dda62 100644 --- a/cpp/src/Ice/PropertyNames.h +++ b/cpp/src/Ice/PropertyNames.h @@ -7,7 +7,7 @@ // // ********************************************************************** -// Generated by makeprops.py from file `../config/PropertyNames.def', Mon Dec 18 13:40:21 2006 +// Generated by makeprops.py from file `./config/PropertyNames.def', Tue Dec 19 14:18:06 2006 // IMPORTANT: Do not edit this file -- any edits made here will be lost! diff --git a/cpp/src/IceUtil/Time.cpp b/cpp/src/IceUtil/Time.cpp index 127dc68f845..22f963f4073 100644 --- a/cpp/src/IceUtil/Time.cpp +++ b/cpp/src/IceUtil/Time.cpp @@ -110,7 +110,7 @@ IceUtil::Time::toMicroSecondsDouble() const } std::string -IceUtil::Time::toDateTime() const +IceUtil::Time::toDateTime(const std::string& format) const { time_t time = static_cast<long>(_usec / 1000000); @@ -124,7 +124,7 @@ IceUtil::Time::toDateTime() const #endif char buf[32]; - strftime(buf, sizeof(buf), "%x %H:%M:%S", t); + strftime(buf, sizeof(buf), format.c_str(), t); std::ostringstream os; os << buf << "."; |