flush output when logging

This commit is contained in:
xenia 2020-11-23 03:21:41 -05:00
parent 13e6eba161
commit 77d012e69a
1 changed files with 4 additions and 2 deletions

View File

@ -57,11 +57,13 @@
[_ "<7>"]))
;; in UTC
(define time-str (date->string (seconds->date (* 0.001 (current-inexact-milliseconds)) #f) #t))
(define time-str
(date->string (seconds->date (* 0.001 (current-inexact-milliseconds)) #f) #t))
;; prefix each line of the log entry with the metadata
(define msg-lines (string-split msg "\n"))
(for ([line (in-list msg-lines)])
(printf "~a[~aZ] [~a] ~a\n" prefix-str time-str level-str line))))
(printf "~a[~aZ] [~a] ~a\n" prefix-str time-str level-str line)
(flush-output (current-output-port)))))
;; process log entries until told to stop
;; this uses the same technique as with-intercepted-logging