How to capture stdout/log output of an agent in SLIME?
Asked Answered
C

2

6

I send a task to an agent, but can't see the output of any print statements I've put into the function. How do I trace code execution on agents?

EDIT: Turns out I do get the output in the console, but not in SLIME. The question now is, how to see the output in SLIME?

Chromogen answered 27/2, 2011 at 8:37 Comment(0)
I
5

The key is to start swank from emacs as the inferior lisp process instead of calling lein swank from the shell. One way to do this is to use elein (the command is M-x elein-swank). Then you can either inspect the output in the inferior lisp buffer (which is called *elein-swank* in the example of using elein), or execute slime-redirect-inferior-output and have the output inline in the repl. Clojure.contrib.logging is a useful tool for sending log output.

Ideologist answered 28/2, 2011 at 5:12 Comment(1)
In more recent versions of clojure-mode, you can do M-x clojure-jack-in to start SLIME and Clojure with STDOUT appearing in the REPL.Accumbent
T
3

You could wrap the calls in your repl in (with-out-str (def result (my-code))) to capture the output as a string. this way you can do it for just the code you're working on and you dont have to restart your repl to start getting your output.

Taperecord answered 28/2, 2011 at 19:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.