From: Siraaj Khandkar Date: Thu, 19 Nov 2020 01:17:21 +0000 (-0500) Subject: Restrict scope of temp variables X-Git-Tag: 0.3.7 X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=26d172a9fb38101f3cc64eed8f2366309d55b9d2;p=tt.git Restrict scope of temp variables --- diff --git a/info.rkt b/info.rkt index a9c77f7..b28beb0 100644 --- a/info.rkt +++ b/info.rkt @@ -6,7 +6,7 @@ (define pkg-desc "twtxt client") (define version - "0.3.6") + "0.3.7") (define pkg-authors '("Siraaj Khandkar ")) (define deps diff --git a/tt.rkt b/tt.rkt index c63f35d..be88095 100644 --- a/tt.rkt +++ b/tt.rkt @@ -230,33 +230,32 @@ (module+ main (require setup/getinfo) - (define (setup-logging) - (define logger (make-logger #f #f 'debug #f)) - (define log-chan (make-log-receiver logger 'debug)) + + (let* ([logger (make-logger #f #f 'debug #f)] + [log-receiver (make-log-receiver logger 'debug)]) (void (thread (λ () [date-display-format 'iso-8601] [let loop () - (define data (sync log-chan)) + (define data (sync log-receiver)) (define level (vector-ref data 0)) (define msg (vector-ref data 1)) (define ts (date->string (current-date) #t)) (eprintf "~a [~a] ~a~n" ts level msg) (loop)]))) (current-logger logger)) - - (setup-logging) (current-http-response-auto #f) (let* ([prog-name "tt"] [prog-version ((get-info (list prog-name)) 'version)] [user-agent (user-agent prog-name prog-version)]) (current-http-user-agent user-agent)) (date-display-format 'rfc2822) - - (define args (current-command-line-arguments)) - (define feeds - (if (= 0 (vector-length args)) - (we-are-twtxt) - (file->feeds (vector-ref args 0)))) - (define out-format 'multi-line) - (define num_workers 15) ; 15 was fastest out of the tried 1, 5, 10, 15 and 20. - (timeline-print out-format (timeline num_workers feeds))) + (let ([feeds + (let ([args (current-command-line-arguments)]) + (if (= 0 (vector-length args)) + (we-are-twtxt) + (file->feeds (vector-ref args 0))))] + [out-format + 'multi-line] + [num_workers + 15]) ; 15 was fastest out of the tried 1, 5, 10, 15 and 20. + (timeline-print out-format (timeline num_workers feeds))))