Changing log destination from the environment

16 views
Skip to first unread message

David Storrs

unread,
Aug 25, 2021, 2:19:23 PM8/25/21
to Racket Users
I've always used loggers in their default form, where they send to the terminal, and then I use tee if I want it to go to a file as well.  That's easy and effective but there's got to be a better way.  Two questions:

1) Is there a way to change logger destinations from the environment such that modifying the code isn't necessary?   (e.g. send it to a file instead of the terminal)

2) Is there a way to make a log message go to multiple destinations at the same time? (e.g. to the terminal and to a file)

My sense is that Racket is explicitly designed to not allow redirecting the logs at runtime, since the documentation makes a point of saying that it sends to the process's *original* error port.  Is that right?

It looks like I could get around this by manually creating log receivers, syncing them in a separate thread, and manually processing the messages that get pumped to them.  I could even have it poll the environment to check for destination CLI arguments. That seems pretty kludgy and I thought I'd ask for a better solution.


I've been through the command line section and the logging section of the docs and am stumped.  If there's a relevant section of the FM that I missed please point me.

https://docs.racket-lang.org/reference/logging.html
Reply all
Reply to author
Forward
0 new messages