[racket] 5.3's "mzc optimizer" log-debug, and log "facility" in general

From: Eli Barzilay (eli at barzilay.org)
Date: Wed Sep 5 07:13:03 EDT 2012

Yesterday, Greg Hendershott wrote:
> - As long as the hood is open, I'd love if a new log-xxx were `format'
> style (more like `error') instead of a single string. i.e. 95% of
> the time I'm typing (log-debug (format ...)).

+1, but see below.

> - I'd want to choose different levels for different modules. Most
> commonly that would be an elevated level for a few specific modules,
> and a lower level for "all other".  For example, "I want 'debug for
> under-dev.rkt, and 'warning for all others".  However there could be
> times when it would be helpful to supply a list of arbitrary (module
> level) pairs. Such as 'debug for foo.rkt, 'info for bar.rkt, 'info
> for baz.rkt, and 'warning for all other.

I forgot about that -- so maybe an imporved extension to the ,log
command would also have these <logspec>s:

  (or  <logspec> ...)
  (and <logspec> ...)  ; <-- for completeness
  (not <logspec>)      ; <--

(which would still require an explicit function to be a syntactic
`lambda' or `λ' form...)

So you can write things like

  ,log (or warning (and debug "/some/prefix"))

But that's just a quick guess at something that would be convenient,
perhaps an explicit function is almost as quick to write, so there's
no need to make a little log-selection language for this...?

> - It would be neat if submodules could somehow be used to mitigate
> the "cost" of logging, as they do for tests or srcdoc. However I
> guess it's apples and oranges?

That's the purpose of `log-warning' etc -- they're macros so they
don't need to evaluate the string unless someone's listening.  And
that's a reason to have just a string argument, though it could
probably be extended to a one or more forms that would be evaluated
only if needed, and used as arguments to `error'.  (And BTW, that
would be an incompatible change, since strings like "foo~bar" that are
used now would need to change to "foo~~bar".)

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

Posted on the users mailing list.