From 20a142f76834668b9e1674010ba5af0b4b441474 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Fri, 17 Jul 2009 18:38:32 +0000 Subject: added timestamp to crash dump log. also did some minor enhancements in formating Signed-off-by: Anand V. Avati BUG: 151 (crash dump log should be in 'logviewer' friendly format) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=151 --- libglusterfs/src/common-utils.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index fb6948d2d86..9efb9625995 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -269,7 +269,7 @@ static void gf_dump_config_flags (int fd) { - write (fd, "configuration details:\n", 22); + write (fd, "configuration details:\n", 23); /* have argp */ #ifdef HAVE_ARGP @@ -364,10 +364,15 @@ gf_dump_config_flags (int fd) void gf_print_trace (int32_t signum) { - extern FILE *gf_log_logfile; - int fd = fileno (gf_log_logfile); - char msg[1024]; + extern FILE *gf_log_logfile; /* don't reset/initialize it, its + an extern */ + int fd = 0; + char msg[1024] = {0,}; + time_t utime = 0; + struct tm *tm = NULL; + char timestr[256] = {0,}; + fd = fileno (gf_log_logfile); /* Pending frames, (if any), list them in order */ write (fd, "pending frames:\n", 16); @@ -405,6 +410,16 @@ gf_print_trace (int32_t signum) sprintf (msg, "signal received: %d\n", signum); write (fd, msg, strlen (msg)); + { + /* Dump the timestamp of the crash too, so the previous logs + can be related */ + utime = time (NULL); + tm = localtime (&utime); + strftime (timestr, 256, "%Y-%m-%d %H:%M:%S\n", tm); + write (fd, "time of crash: ", 15); + write (fd, timestr, strlen (timestr)); + } + gf_dump_config_flags (fd); #if HAVE_BACKTRACE /* Print 'backtrace' */ -- cgit