I'd like to change the format of hi-res timestamps in the broker log (--log-hires-timestamp=yes) from
 1328227878.233328000s
to
 2012-02-02 19:12:54.233328000

Patch attached for review. Any objections? Were there any specific use cases requiring the unformatted form?

Cheers,
Alan.
ffd5842 QPID-3603: Format the seconds part of high-resolution timestamps.

diff --git a/qpid/cpp/src/qpid/log/Logger.cpp b/qpid/cpp/src/qpid/log/Logger.cpp
index 1600822..92578b8 100644
--- a/qpid/cpp/src/qpid/log/Logger.cpp
+++ b/qpid/cpp/src/qpid/log/Logger.cpp
@@ -83,7 +83,7 @@ void Logger::log(const Statement& s, const std::string& msg) {
         if (flags&HIRES)
             qpid::sys::outputHiresNow(os);
         else
-                   qpid::sys::outputFormattedNow(os);
+            qpid::sys::outputFormattedNow(os);
     }
     if (flags&LEVEL)
         os << LevelTraits::name(s.level) << " ";
diff --git a/qpid/cpp/src/qpid/log/Options.cpp b/qpid/cpp/src/qpid/log/Options.cpp
index 0001d00..1259244 100644
--- a/qpid/cpp/src/qpid/log/Options.cpp
+++ b/qpid/cpp/src/qpid/log/Options.cpp
@@ -66,7 +66,7 @@ Options::Options(const std::string& argv0_, const std::string& name_) :
         ("log-source", optValue(source,"yes|no"), "Include source file:line in log messages")
         ("log-thread", optValue(thread,"yes|no"), "Include thread ID in log messages")
         ("log-function", optValue(function,"yes|no"), "Include function signature in log messages")
-        ("log-hires-timestamp", optValue(hiresTs,"yes|no"), "Use unformatted hi-res timestamp in log messages")
+        ("log-hires-timestamp", optValue(hiresTs,"yes|no"), "Use hi-resolution timestamps in log messages")
         ("log-prefix", optValue(prefix,"STRING"), "Prefix to append to all log messages")
         ;
     add(*sinkOptions);
diff --git a/qpid/cpp/src/qpid/sys/posix/Time.cpp b/qpid/cpp/src/qpid/sys/posix/Time.cpp
index 9661f0c..df77e05 100644
--- a/qpid/cpp/src/qpid/sys/posix/Time.cpp
+++ b/qpid/cpp/src/qpid/sys/posix/Time.cpp
@@ -107,7 +107,9 @@ void outputFormattedNow(std::ostream& o) {
 void outputHiresNow(std::ostream& o) {
     ::timespec time;
     ::clock_gettime(CLOCK_REALTIME, &time);
-    o << time.tv_sec << "." << std::setw(9) << std::setfill('0') << time.tv_nsec << "s ";
+    ::time_t seconds = time.tv_sec;
+    outputFormattedTime(o, &seconds);
+    o << "." << std::setw(9) << std::setfill('0') << time.tv_nsec << " ";
 }
 
 void sleep(int secs) {

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to