diff options
Diffstat (limited to 'logger.nim')
-rw-r--r-- | logger.nim | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -40,9 +40,22 @@ proc puts(f: File, s: string) = | |||
40 | proc puts(f: File, r: Rune) = | 40 | proc puts(f: File, r: Rune) = |
41 | f.puts r.toUTF8 | 41 | f.puts r.toUTF8 |
42 | 42 | ||
43 | proc loop*(probe: (timeout: Duration) -> int, getSymbol: (int) -> Rune) = | 43 | func formatTimestampDateTime*(dt: DateTime): string = |
44 | dt.format(TIMESTAMP_FORMAT) | ||
45 | |||
46 | func formatTimestampUnix*(dt: DateTime): string = | ||
47 | ($dt.toTime.toUnix) & " " | ||
48 | |||
49 | func formatTimestampNone*(dt: DateTime): string = | ||
50 | "" | ||
51 | |||
52 | proc 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() |