summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2020-05-08 17:41:35 -0700
committerCommit Bot <commit-bot@chromium.org>2020-05-11 20:29:41 +0000
commit7c2da5bce9c93041777c92711ff02d7672baa916 (patch)
tree9db7bd54cc7ac156e433148155f80f2657ab48b6
parentc411dff46ad0062fe302169b40977861bd7760b2 (diff)
downloadchrome-ec-7c2da5bce9c93041777c92711ff02d7672baa916.tar.gz
gsctool: print sensible date when listing flash log contents
Displaying epoch values in the flash log entries does not help the end user to synchronize the flash log events with other logs generated on the device. This patch changes the log output format to display the device time zone in the first line and then all present log entries with timestamp in 'dd:mm:yy hh:mm:ss' format. BUG=b:153764696 TEST=ran the new gsctool image on a Chrome OS device: $ gsctool -a -L Log time zone is PST Dec 31 69 16:00:01 : 00 May 06 20 21:20:41 : 09 01 ... May 08 20 12:09:21 : 09 00 May 08 20 12:09:22 : 09 03 May 08 20 12:09:23 : 09 06 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: I3fca12e1679fbdd9e0e168606014e84c89c42402 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2191282 Reviewed-by: Namyoon Woo <namyoon@chromium.org>
-rw-r--r--extra/usb_updater/gsctool.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/extra/usb_updater/gsctool.c b/extra/usb_updater/gsctool.c
index 74c4a1b5fc..2f10998682 100644
--- a/extra/usb_updater/gsctool.c
+++ b/extra/usb_updater/gsctool.c
@@ -2463,11 +2463,15 @@ static int process_get_flog(struct transfer_descriptor *td, uint32_t prev_stamp)
int rv;
const int max_retries = 3;
int retries = max_retries;
+ bool time_zone_reported = false;
while (retries--) {
union entry_u entry;
size_t resp_size;
size_t i;
+ struct tm loc_time;
+ time_t entry_epoch;
+ char date_str[25];
resp_size = sizeof(entry);
rv = send_vendor_command(td, VENDOR_CC_POP_LOG_ENTRY,
@@ -2489,7 +2493,18 @@ static int process_get_flog(struct transfer_descriptor *td, uint32_t prev_stamp)
return 0;
memcpy(&prev_stamp, &entry.r.timestamp, sizeof(prev_stamp));
- printf("%10u:%02x", prev_stamp, entry.r.type);
+ entry_epoch = prev_stamp;
+ localtime_r(&entry_epoch, &loc_time);
+
+ if (!time_zone_reported) {
+ strftime(date_str, sizeof(date_str), "%Z", &loc_time);
+ printf("Log time zone is %s\n", date_str);
+ time_zone_reported = true;
+ }
+
+ /* Date format is MMM DD YY HH:mm:ss */
+ strftime(date_str, sizeof(date_str), "%b %d %y %T", &loc_time);
+ printf("%s : %02x", date_str, entry.r.type);
for (i = 0; i < FLASH_LOG_PAYLOAD_SIZE(entry.r.size); i++)
printf(" %02x", entry.r.payload[i]);
printf("\n");