[Larceny-users] stdout from larceny

David Rush kumoyuki at gmail.com
Sat May 31 04:26:13 EDT 2008


On Fri, May 30, 2008 at 12:39 AM, Ray Racine <ray.racine at comcast.net> wrote:
> Longer term I really need to add some logger/trace library for the RL3
> library.

I have one if you want it. I based the API on the logging facilities
we had built into the standard libraries for our server infrastructure
at AOL, so it supports filtering and redirecting log-messages
on-the-fly at a fairly fine level of detail. The code is fairly mature
as I have been using it (or variations thereof) since 2004-ish, and
the best part of it all is that the data is output as s-expressions
for ease of later analysis. A brief summary (excluding quite a few of
the management functions) of the API:

Initializing logs:
(log-file! <log-name> <pred?> <file-name>)
(log-port! <log-name> <pred?> <io-port>)
(log-buffer! <log-name> <pred?> <size>)

Create and install logs to the logging system. The <log-name> is just
a user-friendly handle for retrieving log-objects in a
server-management console (for which there are a number of other
functions). The <pred?> is applied to the <tag-list> associated with
each log message and determines which messages a given log will
record. LOG-BUFFER! creates an in-memory circular buffer of
log-messages, suitable for inspecting from an error REPL or server
console. LOG-PORT! naively writes log messages to a given Scheme
output-port?, but is subject to the buffering and other limits of the
base implementation. LOG-FILE! implements an open/append/close log to
the file named <file-name> for maximum reliability in unstable
environments.

(logit <tag-list> <s-expression>)
(ppit <tag-list> <s-expression>)

Records the <s-expression> into all the logs whose <pred?> evaluates
to #t for the <tag-list>. LOGIT uses the standard WRITE procedure.
PPIT uses the (non-standard, but present in virtually every Scheme
implementation) PRETTY-PRINT procedure, which improve
human-readability when writing large amounts of data to the log.

(log-all . <criteria>)
(log-none . <criteria>)
(log-has-any? . <criteria>)
(log-has? . <criteria>)
(log-fractal? <number-order> . <criteria>)
(log-and . <pred?>)
(log-or . <pred?>)
(log-not  . <pred?>)

Log predicate constructors and combinators. The semantics for these
functions is fairly rich (especially LOG-FRACTAL>) and should be
properly documented. Each of these functions returns a function which
is a suitable predicate for any of the log constructor/installer
functions.

If you are interested in using this code, just pass on a clue, and I
will make it publicly available, either by posting here or on my
web-site.

david rush
-- 
GPG Public key at http://cyber-rush.org/drr/gpg-public-key.txt



More information about the Larceny-users mailing list