summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2009-07-17 18:38:32 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-07-20 14:29:34 -0700
commit20a142f76834668b9e1674010ba5af0b4b441474 (patch)
treeca6ed85b6e2e66c549d5c5bac73470d5e91eac3c
parentf4513b4de104f1c6f40f7bbe0a4bd698340db805 (diff)
added timestamp to crash dump log.
also did some minor enhancements in formating Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 151 (crash dump log should be in 'logviewer' friendly format) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=151
-rw-r--r--libglusterfs/src/common-utils.c23
1 files changed, 19 insertions, 4 deletions
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' */