From 6bf3330d7351c298a193338b0bf08d6b3d698737 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Mon, 17 Jan 2022 20:12:36 +0100 Subject: [PATCH] fix ugly delay logging --- beacon_chain/spec/beacon_time.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/beacon_chain/spec/beacon_time.nim b/beacon_chain/spec/beacon_time.nim index d72d04351..941481d4e 100644 --- a/beacon_chain/spec/beacon_time.nim +++ b/beacon_chain/spec/beacon_time.nim @@ -236,18 +236,20 @@ template start_epoch*(period: SyncCommitteePeriod): Epoch = if period >= maxPeriod: FAR_FUTURE_EPOCH else: Epoch(period * EPOCHS_PER_SYNC_COMMITTEE_PERIOD) -func shortLog*(t: BeaconTime): string = +func `$`*(t: BeaconTime): string = if t.ns_since_genesis >= 0: $(timer.nanoseconds(t.ns_since_genesis)) else: "-" & $(timer.nanoseconds(-t.ns_since_genesis)) -func shortLog*(t: TimeDiff): string = +func `$`*(t: TimeDiff): string = if t.nanoseconds >= 0: $(timer.nanoseconds(t.nanoseconds)) else: "-" & $(timer.nanoseconds(-t.nanoseconds)) +func shortLog*(t: BeaconTime | TimeDiff): string = $t + chronicles.formatIt BeaconTime: it.shortLog chronicles.formatIt TimeDiff: it.shortLog chronicles.formatIt Slot: it.shortLog