Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 241
Alex B Avatar asked Feb 27 '11 08:02

Alex B


2 Answers

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.

like image 79
rplevy Avatar answered Oct 24 '22 17:10

rplevy


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.

like image 25
Arthur Ulfeldt Avatar answered Oct 24 '22 17:10

Arthur Ulfeldt