Re: Logging librarie (Re: Debugging COMM:START-UP-SERVER hang)

"Marco Antoniotti (as marco dot antoniotti at unimib dot it)" <[email protected]>
Newsgroups gmane.lisp.lispworks.general
Message-ID <CAG0Nw2=DjFi1bALYt0ADVJ30FegFkkv6C5Jagh+SQvoWXC2zCA@mail.gmail.com>
Link to slog?

Marco Antoniotti, Professor, Director         tel. +39 - 02 64 48 79 01
DISCo, University of Milan-Bicocca U14 2043   http://dcb.disco.unimib.it
Viale Sarca 336
I-20126 Milan (MI) ITALY

REGAINS: https://regains.disco.unimib.it/

On Sun, Mar 1, 2026, 14:55 Tim Bradshaw <[email protected]> wrote:

> On 28 Feb 2026, at 21:22, Alexey Veretennikov (as alexey dot veretennikov
> at protonmail dot com) <[email protected]> wrote:
> >
> > Personally I don't like too much dependencies, so I just run a logging
> thread/process with a mailbox where I send anything I want to log (or
> eventual shutdown message), take out a message in a loop and print it.
> Seems easier than to learn yet another library.
>
> I have the advantage of having written slog (so I'm blowing my own trumpet
> here), but this is exactly one of the ways I've used it:
>
> (defmethod slog-to ((destination mailbox)
>                     (entry log-entry)
>                     &key)
>   ;; a mailbox is now a log destination
>   (mailbox-send destination entry)
>   entry)
>
> (define-condition terminating-log-entry (log-entry)
>   ;; Just a marker
>   ())
>
> (defun mailbox-log-reader (mailbox &optional (stream *debug-io*))
>   ;; Read log entries and print them till we get a terminating entry
>   (do ((entry (mailbox-read mailbox) (mailbox-read mailbox)))
>       ((typep entry 'terminating-log-entry))
>     (slog-to stream entry)))
>
> (defvar *log-mailbox* (make-mailbox))
>
> (defun ts (n (mailbox *log-mailbox*))
>   (process-run-function
>    "foo" ()
>    (lambda ()
>      ...
>      (logging ((t mailbox))
>        ...
>        (slog "World exploded again")
>        ...
>        (slog 'terminating-log-entry)))))
>
> Slog's trick is that log entries are conditions and logging is signalling
> them.  LOGGING then establishes condition handlers (which always decline to
> handle the condition so control flow just continues) which deal with log
> entries.
>
> It may be that other logging frameworks do the same thing, but they all
> looked too complicated to understand.  The S in slog is for *simple*: I
> wanted to be able to log events not to deal with some awful bureaucracy
> which has seeped out from the Java mines.
>
> --tim
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.