From dbc838fff0b0f157cc13af058f44779e84be65b6 Mon Sep 17 00:00:00 2001 From: Kim van der Riet Date: Mon, 2 May 2011 13:20:36 +0000 Subject: QPID-3236 - Add high-resolution timestamps to log files for debug situations. Windows impl has a stub only. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1098554 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/sys/posix/Time.cpp | 7 +++++++ cpp/src/qpid/sys/windows/Time.cpp | 9 +++++++++ 2 files changed, 16 insertions(+) (limited to 'cpp/src/qpid/sys') diff --git a/cpp/src/qpid/sys/posix/Time.cpp b/cpp/src/qpid/sys/posix/Time.cpp index b3858279b4..9661f0c5e8 100644 --- a/cpp/src/qpid/sys/posix/Time.cpp +++ b/cpp/src/qpid/sys/posix/Time.cpp @@ -27,6 +27,7 @@ #include #include #include +#include namespace { int64_t max_abstime() { return std::numeric_limits::max(); } @@ -103,6 +104,12 @@ void outputFormattedNow(std::ostream& o) { 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 "; +} + void sleep(int secs) { ::sleep(secs); } diff --git a/cpp/src/qpid/sys/windows/Time.cpp b/cpp/src/qpid/sys/windows/Time.cpp index 16d09fcdc0..56eade651a 100644 --- a/cpp/src/qpid/sys/windows/Time.cpp +++ b/cpp/src/qpid/sys/windows/Time.cpp @@ -97,4 +97,13 @@ void outputFormattedNow(std::ostream& o) { &timeinfo); o << time_string << " "; } + +void outputHiresNow(std::ostream& o) { +// TODO: This is a stub - replace with windows code that will do the equivalent +// of the Linux code commented out below. (kpvdr) +// ::timespec time; +// ::clock_gettime(CLOCK_REALTIME, &time); +// o << time.tv_sec << "." << std::setw(9) << std::setfill('0') << time.tv_nsec << "s "; + o << "XXXXXXXXX.XXXXXXXXXs "; +} }} -- cgit v1.2.1