From 903306030f59554ff6fd73146fd30c2330504358 Mon Sep 17 00:00:00 2001 From: euxane Date: Sat, 30 Nov 2024 09:58:49 +0100 Subject: cli: add option for timestamp line header format --- logger.nim | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'logger.nim') diff --git a/logger.nim b/logger.nim index a4d90a0..48aedf2 100644 --- a/logger.nim +++ b/logger.nim @@ -40,9 +40,22 @@ proc puts(f: File, s: string) = proc puts(f: File, r: Rune) = f.puts r.toUTF8 -proc loop*(probe: (timeout: Duration) -> int, getSymbol: (int) -> Rune) = +func formatTimestampDateTime*(dt: DateTime): string = + dt.format(TIMESTAMP_FORMAT) + +func formatTimestampUnix*(dt: DateTime): string = + ($dt.toTime.toUnix) & " " + +func formatTimestampNone*(dt: DateTime): string = + "" + +proc loop*( + probe: (timeout: Duration) -> int, + getSymbol: (int) -> Rune, + timestampHeader: (DateTime) -> string, +) = while true: - stdout.puts now().format(TIMESTAMP_FORMAT) + stdout.puts timestampHeader(now()) for tick in 0..<60: let t = now() -- cgit v1.2.3