Permalink
Browse files

Print ISO date and PID with all error log messages.

The problem is that the currently available fields that compromise
the header of error log messages, which are the date and time, plus
the severity of the message, do not provide the enough information to
identify discontinuity in reporting or which process generated a
message.

To make such identification possible, this change includes the
process ID in the header so that any changes in its value will
identify the source (process) of the message and also indicate any
discontinuity in reporting.

Additionally, the format of the date and time is changed to the ISO
format (YYYY-MM-DD hh:mm:ss). The previous format was non-standard
and difficult to read.
  • Loading branch information...
1 parent 9fa2236 commit e640361c9a1461d33cb7f09da7586c8addbbab36 Davi Arnaut committed Jun 21, 2012
Showing with 18 additions and 11 deletions.
  1. +4 −3 sql/log.cc
  2. +1 −1 storage/innobase/log/log0log.c
  3. +1 −1 storage/innobase/srv/srv0start.c
  4. +12 −6 storage/innobase/ut/ut0ut.c
View
@@ -5891,13 +5891,14 @@ static void print_buffer_to_file(enum loglevel level, const char *buffer,
localtime_r(&skr, &tm_tmp);
start=&tm_tmp;
- fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d [%s] %.*s\n",
- start->tm_year % 100,
- start->tm_mon+1,
+ fprintf(stderr, "%d-%02d-%02d %02d:%02d:%02d %lu [%s] %.*s\n",
+ start->tm_year + 1900,
+ start->tm_mon + 1,
start->tm_mday,
start->tm_hour,
start->tm_min,
start->tm_sec,
+ current_pid,
(level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ?
"Warning" : "Note"),
(int) length, buffer);
@@ -3087,7 +3087,7 @@ logs_empty_and_mark_files_at_shutdown(void)
if (srv_print_verbose_log) {
ut_print_timestamp(stderr);
- fprintf(stderr, " InnoDB: Starting shutdown...\n");
+ 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 */
@@ -2269,7 +2269,7 @@ innobase_shutdown_for_mysql(void)
if (srv_print_verbose_log) {
ut_print_timestamp(stderr);
fprintf(stderr,
- " InnoDB: Shutdown completed;"
+ " InnoDB: Shutdown completed;"
" log sequence number %llu\n",
srv_shutdown_lsn);
}
@@ -39,6 +39,8 @@ Created 5/11/1994 Heikki Tuuri
# include "mysql_com.h" /* NAME_LEN */
#endif /* UNIV_HOTBACKUP */
+#include "os0proc.h" /* os_proc_get_number */
+
/** A constant to prevent the compiler from optimizing ut_delay() away. */
UNIV_INTERN ibool ut_always_false = FALSE;
@@ -232,18 +234,21 @@ ut_print_timestamp(
/*===============*/
FILE* file) /*!< in: file where to print */
{
+ ulint proc_number = os_proc_get_number();
+
#ifdef __WIN__
SYSTEMTIME cal_tm;
GetLocalTime(&cal_tm);
- fprintf(file,"%02d%02d%02d %2d:%02d:%02d",
- (int)cal_tm.wYear % 100,
+ fprintf(file, "%d-%02d-%02d %02d:%02d:%02d %lu",
+ (int)cal_tm.wYear,
(int)cal_tm.wMonth,
(int)cal_tm.wDay,
(int)cal_tm.wHour,
(int)cal_tm.wMinute,
- (int)cal_tm.wSecond);
+ (int)cal_tm.wSecond,
+ proc_number);
#else
struct tm cal_tm;
struct tm* cal_tm_ptr;
@@ -257,13 +262,14 @@ ut_print_timestamp(
#else
cal_tm_ptr = localtime(&tm);
#endif
- fprintf(file,"%02d%02d%02d %2d:%02d:%02d",
- cal_tm_ptr->tm_year % 100,
+ fprintf(file, "%d-%02d-%02d %02d:%02d:%02d %lu",
+ cal_tm_ptr->tm_year + 1900,
cal_tm_ptr->tm_mon + 1,
cal_tm_ptr->tm_mday,
cal_tm_ptr->tm_hour,
cal_tm_ptr->tm_min,
- cal_tm_ptr->tm_sec);
+ cal_tm_ptr->tm_sec,
+ proc_number);
#endif
}

0 comments on commit e640361

Please sign in to comment.