summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <heikki@donna.mysql.fi>2001-05-24 22:35:14 +0300
committerunknown <heikki@donna.mysql.fi>2001-05-24 22:35:14 +0300
commitb6098186662faaef749577b027d49c928a80fa2e (patch)
tree6d16da7ee7c62f996ff34bdabd1a7f6e820d7f9c
parent32d369378e4292a5d859f6edea95f6a396013dfc (diff)
downloadmariadb-git-b6098186662faaef749577b027d49c928a80fa2e.tar.gz
log0log.c InnoDB now prints timestamp at startup and shutdown
srv0start.c InnoDB now prints timestamp at startup and shutdown ut0ut.h InnoDB now prints timestamp at startup and shutdown ut0ut.c InnoDB now prints timestamp at startup and shutdown innobase/ut/ut0ut.c: InnoDB now prints timestamp at startup and shutdown innobase/include/ut0ut.h: InnoDB now prints timestamp at startup and shutdown innobase/srv/srv0start.c: InnoDB now prints timestamp at startup and shutdown innobase/log/log0log.c: InnoDB now prints timestamp at startup and shutdown
-rw-r--r--innobase/include/ut0ut.h7
-rw-r--r--innobase/log/log0log.c8
-rw-r--r--innobase/srv/srv0start.c6
-rw-r--r--innobase/ut/ut0ut.c37
4 files changed, 53 insertions, 5 deletions
diff --git a/innobase/include/ut0ut.h b/innobase/include/ut0ut.h
index f2c4781c167..1e93a2b8a36 100644
--- a/innobase/include/ut0ut.h
+++ b/innobase/include/ut0ut.h
@@ -136,6 +136,13 @@ ut_difftime(
/* out: time2 - time1 expressed in seconds */
ib_time_t time2, /* in: time */
ib_time_t time1); /* in: time */
+/**************************************************************
+Prints a timestamp to a file. */
+
+void
+ut_print_timestamp(
+/*===============*/
+ FILE* file); /* in: file where to print */
/*****************************************************************
Runs an idle loop on CPU. The argument gives the desired delay
in microseconds on 100 MHz Pentium + Visual C++. */
diff --git a/innobase/log/log0log.c b/innobase/log/log0log.c
index 46fcf400d34..31cf595e59e 100644
--- a/innobase/log/log0log.c
+++ b/innobase/log/log0log.c
@@ -2634,8 +2634,9 @@ logs_empty_and_mark_files_at_shutdown(void)
{
dulint lsn;
ulint arch_log_no;
-
- fprintf(stderr, "InnoDB: Starting shutdown...\n");
+
+ ut_print_timestamp(stderr);
+ fprintf(stderr, " InnoDB: Starting shutdown...\n");
/* Wait until the master thread and all other operations are idle: our
algorithm only works if the server is idle at shutdown */
@@ -2725,7 +2726,8 @@ loop:
fil_flush_file_spaces(FIL_TABLESPACE);
- fprintf(stderr, "InnoDB: Shutdown completed\n");
+ ut_print_timestamp(stderr);
+ fprintf(stderr, " InnoDB: Shutdown completed\n");
}
/**********************************************************
diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
index 29ddf2a21c8..b584b663e43 100644
--- a/innobase/srv/srv0start.c
+++ b/innobase/srv/srv0start.c
@@ -813,7 +813,8 @@ innobase_start_or_create_for_mysql(void)
/* Create the thread which watches the timeouts for lock waits */
os_thread_create(&srv_lock_timeout_monitor_thread, NULL,
thread_ids + 2 + SRV_MAX_N_IO_THREADS);
- fprintf(stderr, "InnoDB: Started\n");
+ ut_print_timestamp(stderr);
+ fprintf(stderr, " InnoDB: Started\n");
srv_was_started = TRUE;
srv_is_being_started = FALSE;
@@ -835,8 +836,9 @@ innobase_shutdown_for_mysql(void)
{
if (!srv_was_started) {
if (srv_is_being_started) {
+ ut_print_timestamp(stderr);
fprintf(stderr,
- "InnoDB: Warning: shutting down not properly started database\n");
+ " InnoDB: Warning: shutting down a not properly started database\n");
}
return(DB_SUCCESS);
}
diff --git a/innobase/ut/ut0ut.c b/innobase/ut/ut0ut.c
index cfd714fc275..cae0c3819f3 100644
--- a/innobase/ut/ut0ut.c
+++ b/innobase/ut/ut0ut.c
@@ -49,6 +49,43 @@ ut_difftime(
return(difftime(time2, time1));
}
+/**************************************************************
+Prints a timestamp to a file. */
+
+void
+ut_print_timestamp(
+/*===============*/
+ FILE* file) /* in: file where to print */
+{
+ struct tm* cal_tm_ptr;
+ struct tm cal_tm;
+ time_t tm;
+
+ try_again:
+ time(&tm);
+
+ cal_tm_ptr = localtime(&tm);
+
+ memcpy(&cal_tm, cal_tm_ptr, sizeof(struct tm));
+
+ /* In theory localtime may return a wrong result because its return
+ struct is not protected with a mutex */
+
+ if (difftime(tm, mktime(&cal_tm)) > 0.5
+ || difftime(tm, mktime(&cal_tm)) < -0.5) {
+
+ goto try_again;
+ }
+
+ fprintf(file,"%02d%02d%02d %2d:%02d:%02d",
+ cal_tm.tm_year % 100,
+ cal_tm.tm_mon+1,
+ cal_tm.tm_mday,
+ cal_tm.tm_hour,
+ cal_tm.tm_min,
+ cal_tm.tm_sec);
+}
+
/*****************************************************************
Runs an idle loop on CPU. The argument gives the desired delay
in microseconds on 100 MHz Pentium + Visual C++. */