[PATCH][flatiron]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add timestamps to the corosync-fplay 'black box' output. This makes it much easier/possible to correlate events in other log files when diagnosing problems.

diff --git a/exec/logsys.c b/exec/logsys.c
index cd6a311..816c6de 100644
--- a/exec/logsys.c
+++ b/exec/logsys.c
@@ -1090,6 +1090,7 @@ int _logsys_rec_init (unsigned int fltsize)
 /*
  * u32 RECORD SIZE
  * u32 record ident
+ * u64 time_t timestamp
  * u32 arg count
  * u32 file line
  * u32 subsys length
@@ -1118,6 +1119,7 @@ void _logsys_log_rec (
 	unsigned int arguments = 0;
 	unsigned int record_reclaim_size = 0;
 	unsigned int index_start;
+	struct timeval the_timeval;
 	int words_written;
 	int subsysid;
 
@@ -1178,6 +1180,14 @@ void _logsys_log_rec (
 
 	flt_data[idx++] = records_written;
 	idx_word_step(idx);
+
+	gettimeofday(&the_timeval, NULL);
+	flt_data[idx++] = the_timeval.tv_sec & 0xFFFFFFFF;
+	idx_word_step(idx);
+
+	flt_data[idx++] = the_timeval.tv_sec >> 32;
+	idx_word_step(idx);
+
 	/*
 	 * Encode all of the arguments into the log message
 	 */
diff --git a/tools/corosync-fplay.c b/tools/corosync-fplay.c
index a18bbfc..82f7cb6 100644
--- a/tools/corosync-fplay.c
+++ b/tools/corosync-fplay.c
@@ -411,17 +411,27 @@ static void logsys_rec_print (const void *record)
 	unsigned int words_processed;
 	unsigned int found;
 	const char *arguments[64];
+	time_t timestamp;
+	struct tm timestamp_tm;
 	int arg_count = 0;
+	char ts_buf[132];
 
 	rec_size = buf_uint32t[rec_idx];
 	rec_ident = buf_uint32t[rec_idx+1];
 	line = buf_uint32t[rec_idx+2];
 	record_number = buf_uint32t[rec_idx+3];
 
+	timestamp = (time_t)(buf_uint32t[rec_idx+4] | (time_t)(buf_uint32t[rec_idx+5])<<32);
+
 	level = LOGSYS_DECODE_LEVEL(rec_ident);
 
 	printf ("rec=[%d] ", record_number);
-	arg_size_idx = rec_idx + 4;
+
+	localtime_r(&timestamp, &timestamp_tm);
+	strftime(ts_buf, sizeof(ts_buf), "%F %T", &timestamp_tm);
+	printf ("time=[%s] ", ts_buf);
+
+	arg_size_idx = rec_idx + 6;
 	words_processed = 4;
 	for (i = 0; words_processed < rec_size; i++) {
 		arguments[arg_count++] =
_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss

[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux