This is N/A as of Racket 5.3.1, which added
(Ba da boom. I'm here all week; try the veal.)
Seriously, this is a rethink of Racket's
friends. The main idea is simply to supply a "facility" in addition to
a "level" like
'warning. That way you get more control
over which logging messages you want to ogle_^H^H^H^H_ see, or not.
Many of the procedures are named like Racket's
The core system including
ogl-message doesn't care what the facility
means -- it's
any/c. However the helper macros like
autmatically supply the source file pathname as the facility.
ogl-show lets you specify the level to show, per-facility. This is
similar to using the
,log command in XREPL. For example, to see
'debug level messages for the file in the REPL:
(ogl-show __FILE__ 'debug)
__FILE__ macro identifier saves you typing
"Legacy" code that uses
log-message is wrangled into this under a
'old. In that case, to do useful filtering you have
to supply a predicate that does something lke
regexp-match? on the
message. There are a few predefined predicates, so you can simply say:
(ogl-show 'old 'debug not-GC?) (ogl-show 'old 'debug not-mzc-optimizer?) (ogl-show 'old 'debug not-GC-or-mzc-optimizer?)
These show all "legacy" log messages up to level
for those from the garbage collector or mzc-optimizer.
As long as "the hood is open", one nuisance with
log-debug etc. is
they take only one
string? argument. As a result you type a lot of
(log-debug (format "Status x=~a y=~a" x y))
It would be neater if it were like format:
(log-debug "Status x=~a y=~a" x y)
But what would be even neater is simply this:
(ogl-debug "Status" x y)
In other words,
ogl-debug takes any number of arguments. A literal
is printed as itself, an identifier is printed as identifier=value.
Note that this is backward compatible with
log-debug because you can
ogl-debug with just one, string, argument:
Although the code is fairly well fleshed out, I'm not sure if this is the way to go.
Another approach would be:
Change Racket's docs for
log-messageand friends, to say that "best practice" is to create a named logger for your library or app, and to use only
log-message, specifying that logger.
log-messageprepends the logger name to the message. (But don't use
log-debugetc., because they assume the
current-loggerparameter. Parameters aren't "per-library", so ... that just isn't going to work.)
,logcommand to take a specifier in addition to the level, some kind of predicate that can go a regexp or whatever on the logger name that was put into the message.
This approach is simpler and probably closer to what was intended. On
the other hand it requires everyone to know the right thing to do, and
to do the right thing, including not using the handy
etc. macros. If everyone doesn't do this, you can still get drowned in
their log messages.