Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
ogl is log, rotated. Adding "facility" to Racket logging.
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


This is N/A as of Racket 5.3.1, which added define-logger and racket/format.


ogl is log, rotated.

(Ba da boom. I'm here all week; try the veal.)

Seriously, this is a rethink of Racket's log-message and friends. The main idea is simply to supply a "facility" in addition to a "level" like 'debug or '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 log-xxx procedures, but ogl-xxx instead.

The core system including ogl-message doesn't care what the facility means -- it's any/c. However the helper macros like ogl-debug 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)

(The __FILE__ macro identifier saves you typing /home/src/path/to/foo.rkt.)

"Legacy" code that uses log-message is wrangled into this under a facility called '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 'debug, except for those from the garbage collector or mzc-optimizer.

ogl-debug etc.

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 stuff like:

(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 call ogl-debug with just one, string, argument:

 (ogl-debug "hi")


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-message and 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-message prepends the logger name to the message. (But don't use log-debug etc., because they assume the current-logger parameter. Parameters aren't "per-library", so ... that just isn't going to work.)

  • Change XREPL's ,log command 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 log-debug etc. macros. If everyone doesn't do this, you can still get drowned in their log messages.

Something went wrong with that request. Please try again.