How can I set environment variables in racket-mode?

I'd like to have the racket-mode repl show logging. I've browsed through the docs and don't see anything like that...can anyone offer a pointer?

1 Like

I think you want to look at the settings here: Racket Mode

1 Like

Thanks, that helps.

One further request: It spits the logging out into a dedicated buffer instead of in the same repl where I see the results of the code. I won't say that's useless, but it's definitely use-impaired. Is there a way to get it to behave the way it would if run from the command line?

I don't know of one, but I would just open an issue on the racket-mode repository and @greghendershott will probably respond.

1 Like

I suppose it depends on your use scenario.

For me, the advantages of logging compared to normal print include:

  • the topics and levels can be adjusted while your program keeps running (don't need to change/restart your program)
  • when my program uses multiple threads, all their logging output is serialized nicely (I don't get "concurrency problems output order" :slight_smile:)
  • similarly I can be at a REPL prompt, and be typing some new expression, while other threads continue to run and logger output goes somewhere other than on top of my REPL interaction

From that point of view, I've found it super useful and natural to have a dedicated buffer, with a topic/level changing UI.

But. If you prefer logger output mixed together with your program's output, REPL input, and REPL printed results -- all four together? You could change your program to add a little log receiver that displaylns each logger message. In other words make the logger output be part of your program's output. That's the only "work around" I have right now. I'd be glad to take a feature request on the repo.

1 Like

Interesting. How does that work, exactly? Is it updating the current-logger parameter?

Erm...how are you guaranteeing nice serialization when the order that threads run isn't guaranteed? I've worked around this by using the thread-with-id module so that each thread has a unique ID that I can use to collate the messages, but if there's a better way then I'd like to know.

It (re)creates a log reciever that asks for the desired topics and levels.

As for concurrency, all I mean is that you don't get the messages written "on top of each other". If you have multiple threads doing displayln, eventually you're likely to see things like:

I am about to get hey I'm th eparty crasher message from thread 2
interrupted in the middle

and if it's in a REPL that's also displaying the results of evaluating expressions, as well as what input that you're typing, it can become un-fun.

So the idea of using a dedicated buffer wasn't intended to be "use-impaired". It was supposed to be a better experience, and worth the work to create that vs. just writing routing logger messages to current-output-port and into the REPL buffer, along with everything else doing that concurrently. :man_shrugging:

But I understand if your program has just one thread, it may not matter, and you'd prefer to see the logger output in the REPL.

It's actually got a bunch of threads, but I haven't seen the issue you're describing. Anyway, thank you for the explanation. It helps.