How can I see the stdout for processes in sweeprolog?

Say I’m working on a server, that I start with a call like http_server(http_dispatch, [port(Port)])., right in the sweep top-level.

And in the server code I sometimes use format/1, but I don’t see any output in the top-level nor in any buffers in emacs. Compare this to running the server from a swipl top level, where I get to see the output. How can I see what is been printed?

@oskardrums

Of course, just after I posted this question, I found the async query functionality at
Sweep: SWI-Prolog Embedded in Emacs, but interestingly the output I get is:

starting server on port 8081
Sweep async goal finished

Process ?- server:start. finished

The code for server:start was:

start :-
    Port = 8081,
    format('starting server on port ~w', [Port]),
    http_server(http_dispatch, [port(Port)]).

In the meanwhile, the server still runs, and the result is not showed in the async goal buffer.

It seems that the premise of the question was wrong. The problem is that I should have used:

    format(user_output,"Node was: ~k~n",[Node]).

instead of

    format("Node was: ~k~n",[Node]).

as I had done before, but forgot. If I do this, everything works as I expected. I’ll leave the question here nonetheless because it could be useful to someone else that encouters the same pitfall.

1 Like

Thanks for seeing this through and finding a solution. If you think there’s something to improve here, including the documentation, let me know.

I don’t think your premise was wrong, but I’m not sure I understand the exact issue you were facing. Namely, you should be able to see the output of format/2 in Sweep top-level buffers without specifying user_output as the output stream. I get:

?- format("Node was: ~k~n",[foo]).
Node was: foo
true.