#At file:///home/lb200670/devel/mysql/checkin/
2859 lars-erik.bjork@stripped 2008-10-07
This is a fix for bug#39647 (Warning about slow serial log writes should be prefixed
with time stamp)
This fix prefixes time stamps on all messages sent through the interface provided by
the Log class. StorageInterface::logger is registered as a receiver of the log, and
all messages received are prefixed before being printed. This ensures that other
future/historic receivers of the log are not forced to have the Falcon specific time
stamp. The time stamps are on the format YYMMDD (h)h:mm:ss, to be in line with the
time stamps printed by the server and by InnoDB.
modified:
storage/falcon/ha_falcon.cpp
=== modified file 'storage/falcon/ha_falcon.cpp'
--- a/storage/falcon/ha_falcon.cpp 2008-10-03 05:15:40 +0000
+++ b/storage/falcon/ha_falcon.cpp 2008-10-07 07:18:30 +0000
@@ -19,6 +19,8 @@
#define MYSQL_SERVER
#endif
+#include <time.h>
+
#include "mysql_priv.h"
#include "falcon_probes.h"
@@ -173,6 +175,38 @@ bool checkExceptionSupport()
return false;
}
+void getTimestamp(int length, char* buffer)
+{
+#ifdef __WIN__
+ SYSTEMTIME now;
+ GetLocalTime(&now);
+ snprintf(buffer, length, "%.2d%.2d%.2d %2d:%.2d:%.2d",
+ (int)now.wYear % 100,
+ (int)now.wMonth,
+ (int)now.wDay,
+ (int)now.wHour,
+ (int)now.wMinute,
+ (int)now.wSecond);
+#else
+ struct tm result;
+ time_t now;
+ time(&now);
+#ifdef HAVE_LOCALTIME_R
+ struct tm* time_ptr = localtime_r(&now, &result);
+#else
+ struct tm* time_ptr = localtime(&now);
+ result = *time_ptr;
+#endif
+ snprintf(buffer, length, "%.2d%.2d%.2d %2d:%.2d:%.2d",
+ (int)result.tm_year % 100,
+ (int)result.tm_mon + 1,
+ (int)result.tm_mday,
+ (int)result.tm_hour,
+ (int)result.tm_min,
+ (int)result.tm_sec);
+#endif
+}
+
int StorageInterface::falcon_init(void *p)
{
DBUG_ENTER("falcon_init");
@@ -2358,12 +2392,14 @@ void StorageInterface::logger(int mask,
{
if (mask & falcon_debug_mask)
{
- printf("%s", text);
+ char time[256];
+ getTimestamp(sizeof(time), time);
+ printf("%s Falcon: %s", time, text);
fflush(stdout);
if (falcon_log_file)
{
- fprintf(falcon_log_file, "%s", text);
+ fprintf(falcon_log_file, "%s Falcon: %s", time, text);
fflush(falcon_log_file);
}
}