diff mbox series

Print timestamps

Message ID b0b1bf3047ca4dfc87c4dbe2b8d2a4e8@sieb-meyer.de
State New
Headers show
Series Print timestamps | expand

Commit Message

Buhrow, Simon June 18, 2019, 10:29 a.m. UTC
Hi,

sometimes I like to know how long an operation took or when I started programming.
That´s why I added some timestamp printouts.

May be you want to add it to the sources or do it in a more elegant way? 
What´s about adding the timestamp printout to msg_cinfo ?

Just a proposal...

Regards,

Simon
Signed-off-by: simon Buhrow <simon.buhrow@sieb-meyer.de>
diff mbox series

Patch

--- flashrom_orig.c	2019-06-03 14:01:40.000000000 +0200
+++ flashrom.c	2019-06-18 11:19:36.401779000 +0200
@@ -31,6 +31,7 @@ 
 #include <errno.h>
 #include <ctype.h>
 #include <getopt.h>
+#include <time.h>
 #if HAVE_UTSNAME == 1
 #include <sys/utsname.h>
 #endif
@@ -58,6 +59,9 @@ 
 /* Is writing allowed with this programmer? */
 int programmer_may_write;
 
+time_t t;
+
+
 const struct programmer_entry programmer_table[] = {
 #if CONFIG_INTERNAL == 1
 	{
@@ -1679,6 +1683,8 @@ 
 	const struct flashrom_layout *const layout = get_layout(flashctx);
 
 	all_skipped = true;
+    time(&t);
+    msg_cinfo(" current time is : %s",ctime(&t));
 	msg_cinfo("Erasing and writing flash chip... ");
 
 	size_t i;
@@ -1703,6 +1709,8 @@ 
 				break;
 
 			if (info->curcontents) {
+                time(&t);
+                msg_cinfo(" current time is : %s",ctime(&t));
 				msg_cinfo("Reading current flash chip contents... ");
 				if (read_by_layout(flashctx, info->curcontents)) {
 					/* Now we are truly screwed. Read failed as well. */
@@ -2527,6 +2535,8 @@ 
 		 * preserved, but in that case we might perform unneeded erase which
 		 * takes time as well.
 		 */
+        time(&t);
+        msg_cinfo("\n current time is : %s",ctime(&t));
 		msg_cinfo("Reading old flash chip contents... ");
 		if (verify_all) {
 			if (flashctx->chip->read(flashctx, oldcontents, 0, flash_size)) {
@@ -2570,7 +2580,8 @@ 
 	/* Verify only if we actually changed something. */
 	if (verify && !all_skipped) {
 		const struct flashrom_layout *const layout_bak = flashctx->layout;
-
+        time(&t);
+        msg_cinfo(" current time is : %s",ctime(&t));
 		msg_cinfo("Verifying flash... ");
 
 		/* Work around chips which need some time to calm down. */
@@ -2588,6 +2599,8 @@ 
 			emergency_help_message();
 		else
 			msg_cinfo("VERIFIED.\n");
+        time(&t);
+        msg_cinfo(" current time is : %s",ctime(&t));
 	} else {
 		/* We didn't change anything. */
 		ret = 0;