From 0538f21274720a6deb5ff6575843f4b081eeb832 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Wed, 1 Jun 2011 15:24:15 -0400 Subject: [PATCH] Make level a keyword argument for with-logging-to-port. --- collects/unstable/logging.rkt | 9 ++++----- collects/unstable/scribblings/logging.scrbl | 11 ++++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/collects/unstable/logging.rkt b/collects/unstable/logging.rkt index f5747f1a95..9d2a7018ce 100644 --- a/collects/unstable/logging.rkt +++ b/collects/unstable/logging.rkt @@ -11,7 +11,7 @@ ;; (log-warning "not ok") ;; If the logging on the last line is executed before the thread listening ;; to the logs sees the stop message, "not ok" will also be sent to port. -(define (with-logging-to-port port level proc) +(define (with-logging-to-port port proc #:level [level 'debug]) (let* ([logger (make-logger #f (current-logger))] [receiver (make-log-receiver logger level)] [stop-chan (make-channel)] @@ -41,7 +41,6 @@ (thread-wait t)))) (provide/contract [with-logging-to-port - (-> output-port? - (or/c 'fatal 'error 'warning 'info 'debug) - (-> any) - any)]) + (->* (output-port? (-> any)) + (#:level (or/c 'fatal 'error 'warning 'info 'debug)) + any)]) diff --git a/collects/unstable/scribblings/logging.scrbl b/collects/unstable/scribblings/logging.scrbl index 0348fc995b..9069afd6fd 100644 --- a/collects/unstable/scribblings/logging.scrbl +++ b/collects/unstable/scribblings/logging.scrbl @@ -10,9 +10,9 @@ This module provides tools for logging. @unstable[@author+email["Vincent St-Amour" "stamourv@racket-lang.org"]] -@defproc[(with-logging-to-port [port output-port?] - [level (or/c 'fatal 'error 'warning 'info 'debug)] - [proc (-> any)]) +@defproc[(with-logging-to-port + [port output-port?] [proc (-> any)] + [#:level level (or/c 'fatal 'error 'warning 'info 'debug) 'info]) any]{ Runs @racket[proc], outputting any logging of level @racket[level] or higher to @@ -21,10 +21,11 @@ Runs @racket[proc], outputting any logging of level @racket[level] or higher to @defexamples[ #:eval (eval/require 'unstable/logging) (let ([my-log (open-output-string)]) - (with-logging-to-port my-log 'warning + (with-logging-to-port my-log (lambda () (log-warning "Warning World!") - (+ 2 2))) + (+ 2 2)) + #:level 'warning) (display (get-output-string my-log))) ]