如何在 SLIME 中捕获代理的 stdout/log 输出?
我将任务发送给代理,但看不到我放入该函数中的任何打印语句的输出。如何跟踪代理上的代码执行情况?
编辑: 结果我确实在控制台中得到了输出,但在 SLIME 中却没有。现在的问题是,如何在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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
关键是从 emacs 启动 swank 作为下级 lisp 进程,而不是从 shell 调用 lein swank。一种方法是使用 elein (命令为
MX elein-swank
)。然后,您可以检查下级 lisp 缓冲区中的输出(在使用 elein 的示例中称为 *elein-swank*),或者执行 slime-redirect-inferior-output code> 并将输出内联在 repl 中。 Clojure.contrib.logging 是发送日志输出的有用工具。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 executeslime-redirect-inferior-output
and have the output inline in the repl. Clojure.contrib.logging is a useful tool for sending log output.您可以将 repl 中的调用包装在
(with-out-str (def result (my-code)))
中,以将输出捕获为字符串。这样你就可以只对你正在处理的代码执行此操作,而不必重新启动你的 repl 来开始获取输出。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.