[racket] Logging

From: Eli Barzilay (eli at barzilay.org)
Date: Sat Dec 11 17:09:27 EST 2010

On Wednesday, Russell Adams wrote:
> Does anyone have a good example of using the built-in logger and log
> levels, particularly how one can alter the log-level on the fly
> without restarting (to pass a CLI parameter or change an ENV var).

I've already mentioned my interactive thing as a place that does that.
Here's a small piece of code that I extracted from there, that starts
a thread to print info-level log events:

  (let ([r (make-log-receiver (current-logger) 'info)])
     (lambda ()
       (let loop ()
         (match (sync r)
           [(vector l m v)
            (printf ";; [~a] ~a~a\n" l m (if v (format " ~.s" v) ""))

If you try to evaluate something like (define (foo) (-)) before the
above you won't see anything, and after the above you'll see the
compiler warnings.

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the users mailing list.