aboutsummaryrefslogtreecommitdiff
path: root/logger.nim
diff options
context:
space:
mode:
authoreuxane2024-11-30 09:58:49 +0100
committereuxane2024-11-30 09:58:49 +0100
commit903306030f59554ff6fd73146fd30c2330504358 (patch)
tree2c6063901e45b576100d6c312a68f453ef7b9dc7 /logger.nim
parentdc2ec09d6d29913d696f0ea9dc5d035542c792e8 (diff)
downloadtickwatch-903306030f59554ff6fd73146fd30c2330504358.tar.gz
cli: add option for timestamp line header format
Diffstat (limited to 'logger.nim')
-rw-r--r--logger.nim17
1 files changed, 15 insertions, 2 deletions
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) =
40proc puts(f: File, r: Rune) = 40proc puts(f: File, r: Rune) =
41 f.puts r.toUTF8 41 f.puts r.toUTF8
42 42
43proc loop*(probe: (timeout: Duration) -> int, getSymbol: (int) -> Rune) = 43func formatTimestampDateTime*(dt: DateTime): string =
44 dt.format(TIMESTAMP_FORMAT)
45
46func formatTimestampUnix*(dt: DateTime): string =
47 ($dt.toTime.toUnix) & " "
48
49func formatTimestampNone*(dt: DateTime): string =
50 ""
51
52proc loop*(
53 probe: (timeout: Duration) -> int,
54 getSymbol: (int) -> Rune,
55 timestampHeader: (DateTime) -> string,
56) =
44 while true: 57 while true:
45 stdout.puts now().format(TIMESTAMP_FORMAT) 58 stdout.puts timestampHeader(now())
46 59
47 for tick in 0..<60: 60 for tick in 0..<60:
48 let t = now() 61 let t = now()