summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2010-12-02 20:14:56 +0000
committerSteve Huston <shuston@riverace.com>2010-12-02 20:14:56 +0000
commite0f68e00987eabe3916a2d117b33ac4ce747bb1c (patch)
treec63c038d0714eab7a384df76f531f75f879b830f
parent06d606acee020bac9ab442f125c69388e363c541 (diff)
downloadATCD-e0f68e00987eabe3916a2d117b33ac4ce747bb1c.tar.gz
ChangelogTag:Thu Dec 2 18:29:36 UTC 2010 Steve Huston <shuston@riverace.com>
-rw-r--r--ACE/ChangeLog13
-rw-r--r--ACE/NEWS7
-rw-r--r--ACE/ace/ACE.cpp97
-rw-r--r--ACE/ace/ACE.h50
-rw-r--r--ACE/ace/Log_Record.cpp29
5 files changed, 77 insertions, 119 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog
index fc2b9f17817..1694b348e15 100644
--- a/ACE/ChangeLog
+++ b/ACE/ChangeLog
@@ -1,3 +1,16 @@
+Thu Dec 2 18:29:36 UTC 2010 Steve Huston <shuston@riverace.com>
+
+ * ace/ACE.{h cpp} (timestamp): Changed the format produced from
+ ACE::timestamp() from ctime-ish "Day Mon dd hh:mm:ss yyyy" to
+ ISO-8601 yyyy-mm-dd hh:mm:ss.mmmmmm. Thank you to Thomas
+ Lockhart for this fix. Resolves Bugzilla #3210.
+ Also fixed up the doxygen comments related.
+
+ * ace/Log_Record.cpp (format_msg): VERBOSE[_LITE] timestamp also
+ changed to ISO-8601 format but uses 3 decimal places after secs.
+
+ * NEWS: Described above change for users.
+
Mon Nov 29 17:20:47 UTC 2010 Jeff Parsons <j.parsons@vanderbilt.edu>
* THANKS:
diff --git a/ACE/NEWS b/ACE/NEWS
index e88c7638e71..3c0c3b7cde9 100644
--- a/ACE/NEWS
+++ b/ACE/NEWS
@@ -1,6 +1,13 @@
USER VISIBLE CHANGES BETWEEN ACE-5.8.3 and ACE-6.0.0
====================================================
+. Changed the string format produced by ACE::timestamp() from the ctime
+ format "Day Mon dd hh:mm:ss yyyy" to ISO-8601 yyyy-mm-dd hh:mm:ss.mmmmmm.
+ This makes the time easier to collate and removes any dependence on locale.
+ The change affects the output from ACE_Log_Msg's %D format and both VERBOSE
+ and VERBOSE_LIGHT timestamps in addition to application-made direct calls
+ to ACE::timestamp().
+
. Removed GCC < 3 support
. A new build system hook was added for users to include site-private rules
diff --git a/ACE/ace/ACE.cpp b/ACE/ace/ACE.cpp
index cc53d260c1e..d3238d10123 100644
--- a/ACE/ace/ACE.cpp
+++ b/ACE/ace/ACE.cpp
@@ -2371,7 +2371,8 @@ ACE::format_hexdump (const char *buffer,
// Returns the current timestamp in the form
// "hour:minute:second:microsecond." The month, day, and year are
-// also stored in the beginning of the date_and_time array.
+// also stored in the beginning of the date_and_time array
+// using ISO-8601 format.
ACE_TCHAR *
ACE::timestamp (ACE_TCHAR date_and_time[],
@@ -2386,7 +2387,8 @@ ACE::timestamp (ACE_TCHAR date_and_time[],
// Returns the given timestamp in the form
// "hour:minute:second:microsecond." The month, day, and year are
-// also stored in the beginning of the date_and_time array.
+// also stored in the beginning of the date_and_time array
+// using ISO-8601 format.
ACE_TCHAR *
ACE::timestamp (const ACE_Time_Value& time_value,
@@ -2396,92 +2398,29 @@ ACE::timestamp (const ACE_Time_Value& time_value,
{
//ACE_TRACE ("ACE::timestamp");
- if (date_and_timelen < 35)
+ if (date_and_timelen < 27)
{
errno = EINVAL;
return 0;
}
-#if defined (WIN32)
- if (time_value == ACE_Time_Value::zero)
- {
- // Emulate Unix. Win32 does NOT support all the UNIX versions
- // below, so DO we need this ifdef.
- static const ACE_TCHAR *day_of_week_name[] =
- {
- ACE_TEXT ("Sun"),
- ACE_TEXT ("Mon"),
- ACE_TEXT ("Tue"),
- ACE_TEXT ("Wed"),
- ACE_TEXT ("Thu"),
- ACE_TEXT ("Fri"),
- ACE_TEXT ("Sat")
- };
-
- static const ACE_TCHAR *month_name[] =
- {
- ACE_TEXT ("Jan"),
- ACE_TEXT ("Feb"),
- ACE_TEXT ("Mar"),
- ACE_TEXT ("Apr"),
- ACE_TEXT ("May"),
- ACE_TEXT ("Jun"),
- ACE_TEXT ("Jul"),
- ACE_TEXT ("Aug"),
- ACE_TEXT ("Sep"),
- ACE_TEXT ("Oct"),
- ACE_TEXT ("Nov"),
- ACE_TEXT ("Dec")
- };
-
- SYSTEMTIME local;
- ::GetLocalTime (&local);
-
- ACE_OS::sprintf (date_and_time,
- ACE_TEXT ("%3s %3s %2d %04d %02d:%02d:%02d.%06d"),
- day_of_week_name[local.wDayOfWeek],
- month_name[local.wMonth - 1],
- (int) local.wDay,
- (int) local.wYear,
- (int) local.wHour,
- (int) local.wMinute,
- (int) local.wSecond,
- (int) (local.wMilliseconds * 1000));
- return &date_and_time[15 + (return_pointer_to_first_digit != 0)];
- }
-#endif /* WIN32 */
- ACE_TCHAR timebuf[26]; // This magic number is based on the ctime(3c) man page.
ACE_Time_Value cur_time =
(time_value == ACE_Time_Value::zero) ?
ACE_Time_Value (ACE_OS::gettimeofday ()) : time_value;
time_t secs = cur_time.sec ();
-
- ACE_OS::ctime_r (&secs,
- timebuf,
- sizeof timebuf / sizeof (ACE_TCHAR));
- // date_and_timelen > sizeof timebuf!
- ACE_OS::strsncpy (date_and_time,
- timebuf,
- date_and_timelen);
- ACE_TCHAR yeartmp[5];
- ACE_OS::strsncpy (yeartmp,
- &date_and_time[20],
- 5);
- ACE_TCHAR timetmp[9];
- ACE_OS::strsncpy (timetmp,
- &date_and_time[11],
- 9);
- ACE_OS::sprintf (&date_and_time[11],
-# if defined (ACE_USES_WCHAR)
- ACE_TEXT ("%ls %ls.%06ld"),
-# else
- ACE_TEXT ("%s %s.%06ld"),
-# endif /* ACE_USES_WCHAR */
- yeartmp,
- timetmp,
- cur_time.usec ());
- date_and_time[33] = '\0';
- return &date_and_time[15 + (return_pointer_to_first_digit != 0)];
+ struct tm tms;
+ ACE_OS::localtime_r (&secs, &tms);
+ ACE_OS::sprintf (date_and_time,
+ ACE_TEXT ("%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d.%06ld"),
+ tms.tm_year + 1900,
+ tms.tm_mon + 1,
+ tms.tm_mday,
+ tms.tm_hour,
+ tms.tm_min,
+ tms.tm_sec,
+ cur_time.usec());
+ date_and_time[26] = '\0';
+ return &date_and_time[11 + (return_pointer_to_first_digit != 0)];
}
// This function rounds the request to a multiple of the page size.
diff --git a/ACE/ace/ACE.h b/ACE/ace/ACE.h
index 38ad1b67779..2f4ecbead6e 100644
--- a/ACE/ace/ACE.h
+++ b/ACE/ace/ACE.h
@@ -474,15 +474,23 @@ namespace ACE
ACE_DIRECTORY_SEPARATOR_CHAR);
/**
- * Returns the given timestamp in the form
- * "hour:minute:second:microsecond." The month, day, and year are
- * also stored in the beginning of the @a date_and_time array, which
- * is a user-supplied array of size @a time_len> @c ACE_TCHARs.
- * Returns 0 if unsuccessful, else returns pointer to beginning of the
- * "time" portion of @a date_and_time. If @a
- * return_pointer_to_first_digit is 0 then return a pointer to the
- * space before the time, else return a pointer to the beginning of
- * the time portion.
+ * Translate the given timestamp to ISO-8601 format.
+ *
+ * @param time_value ACE_Time_Value to format. This is assumed to be
+ * an absolute time value.
+ * @param date_and_time Array to hold the timestamp.
+ * @param time_len Size of @a date_and_time in ACE_TCHARs.
+ * Must be greater than or equal to 27.
+ * @param return_pointer_to_first_digit If true, returned pointer value
+ * is to the first time digit, else to the space
+ * prior to the first time digit. See Return Values.
+ *
+ * @retval 0 if unsuccessful, with errno set. If @a time_len is less than
+ * 27 errno will be EINVAL.
+ * @retval If successful, pointer to beginning of the "time" portion of
+ * @a date_and_time. If @a return_pointer_to_first_digit is false
+ * the pointer is actually to the space before the time, else
+ * the pointer is to the first time digit.
*/
extern ACE_Export ACE_TCHAR *timestamp (const ACE_Time_Value& time_value,
ACE_TCHAR date_and_time[],
@@ -490,15 +498,21 @@ namespace ACE
bool return_pointer_to_first_digit = false);
/**
- * Returns the current timestamp in the form
- * "hour:minute:second:microsecond." The month, day, and year are
- * also stored in the beginning of the @a date_and_time array, which
- * is a user-supplied array of size @a time_len> @c ACE_TCHARs.
- * Returns 0 if unsuccessful, else returns pointer to beginning of the
- * "time" portion of @a date_and_time. If @a
- * return_pointer_to_first_digit is 0 then return a pointer to the
- * space before the time, else return a pointer to the beginning of
- * the time portion.
+ * Translate the current time to ISO-8601 timestamp format.
+ *
+ * @param date_and_time Array to hold the timestamp.
+ * @param time_len Size of @a date_and_time in ACE_TCHARs.
+ * Must be greater than or equal to 27.
+ * @param return_pointer_to_first_digit If true, returned pointer value
+ * is to the first time digit, else to the space
+ * prior to the first time digit. See Return Values.
+ *
+ * @retval 0 if unsuccessful, with errno set. If @a time_len is less than
+ * 27 errno will be EINVAL.
+ * @retval If successful, pointer to beginning of the "time" portion of
+ * @a date_and_time. If @a return_pointer_to_first_digit is false
+ * the pointer is actually to the space before the time, else
+ * the pointer is to the first time digit.
*/
extern ACE_Export ACE_TCHAR *timestamp (ACE_TCHAR date_and_time[],
size_t time_len,
diff --git a/ACE/ace/Log_Record.cpp b/ACE/ace/Log_Record.cpp
index b562103532b..fb7ae019708 100644
--- a/ACE/ace/Log_Record.cpp
+++ b/ACE/ace/Log_Record.cpp
@@ -214,18 +214,16 @@ ACE_Log_Record::format_msg (const ACE_TCHAR host_name[],
u_long verbose_flag,
ACE_TCHAR *verbose_msg)
{
- /* 0123456789012345678901234 */
- /* Oct 18 14:25:36.000 1989<nul> */
- ACE_TCHAR timestamp[26]; // Only used by VERBOSE and VERBOSE_LITE.
+ /* 012345678901234567890123456 */
+ /* yyyy-mm-dd hh:mm:ss.mmmmmm<nul> */
+ ACE_TCHAR timestamp[27]; // Only used by VERBOSE and VERBOSE_LITE.
// The sprintf format needs to be different for Windows and POSIX
// in the wide-char case.
#if defined (ACE_WIN32) || !defined (ACE_USES_WCHAR)
- const ACE_TCHAR *time_fmt = ACE_TEXT ("%s.%03ld %s");
const ACE_TCHAR *verbose_fmt = ACE_TEXT ("%s@%s@%u@%s@%s");
const ACE_TCHAR *verbose_lite_fmt = ACE_TEXT ("%s@%s@%s");
#else
- const ACE_TCHAR *time_fmt = ACE_TEXT ("%ls.%03ld %ls");
const ACE_TCHAR *verbose_fmt = ACE_TEXT ("%ls@%ls@%u@%ls@%ls");
const ACE_TCHAR *verbose_lite_fmt = ACE_TEXT ("%ls@%ls@%ls");
#endif
@@ -235,23 +233,10 @@ ACE_Log_Record::format_msg (const ACE_TCHAR host_name[],
|| ACE_BIT_ENABLED (verbose_flag,
ACE_Log_Msg::VERBOSE_LITE))
{
- time_t const now = this->secs_;
- ACE_TCHAR ctp[26]; // 26 is a magic number...
-
- if (ACE_OS::ctime_r (&now, ctp, sizeof ctp / sizeof (ACE_TCHAR)) == 0)
- return -1;
-
- /* 01234567890123456789012345 */
- /* Wed Oct 18 14:25:36 1989n0 */
-
- ctp[19] = '\0'; // NUL-terminate after the time.
- ctp[24] = '\0'; // NUL-terminate after the date.
-
- ACE_OS::sprintf (timestamp,
- time_fmt,
- ctp + 4,
- ((long) this->usecs_) / 1000,
- ctp + 20);
+ ACE_Time_Value now (this->secs_, this->usecs_);
+ ACE::timestamp (now, timestamp, 27);
+ // Historical timestamp in VERBOSE[_LITE] used 3 places for partial sec.
+ timestamp[23] = '\0';
}
if (ACE_BIT_ENABLED (verbose_flag,