From 54e443809e09b8cc7ae05fdf02e80775a1bb71e6 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 14 Feb 2012 16:11:42 +0000 Subject: QPID-3603: Format the seconds part of high-resolution timestamps. Hi-res timestamps are now formatted like this: 2012-02-02 17:40:20.236067000 git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/qpid-3603-6@1244102 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/qpid/log/Logger.cpp | 2 +- qpid/cpp/src/qpid/log/Options.cpp | 2 +- qpid/cpp/src/qpid/sys/posix/Time.cpp | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/qpid/cpp/src/qpid/log/Logger.cpp b/qpid/cpp/src/qpid/log/Logger.cpp index 8c995a5c32..c4ce025547 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 0001d00bdf..1259244297 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 dee393f4bf..272c6c21a5 100644 --- a/qpid/cpp/src/qpid/sys/posix/Time.cpp +++ b/qpid/cpp/src/qpid/sys/posix/Time.cpp @@ -114,7 +114,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) { -- cgit v1.2.1