# How can I see the stdout for processes in sweeprolog?

**URL:** <https://swi-prolog.discourse.group/t/how-can-i-see-the-stdout-for-processes-in-sweeprolog/6743>\
**Category:** General\
**Created:** [July 25, 2023, 3:36pm UTC](https://swi-prolog.discourse.group/t/how-can-i-see-the-stdout-for-processes-in-sweeprolog/6743 "2023-07-25T15:36:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![meditans](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/meditans/32/1768_2.png) [@meditans](https://swi-prolog.discourse.group/u/meditans)\
**Post date:** [July 25, 2023, 3:36pm UTC](https://swi-prolog.discourse.group/t/how-can-i-see-the-stdout-for-processes-in-sweeprolog/6743/1 "2023-07-25T15:36:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![meditans](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/meditans/32/1768_2.png) [@meditans](https://swi-prolog.discourse.group/u/meditans)\
**Post date:** [July 25, 2023, 3:41pm UTC](https://swi-prolog.discourse.group/t/how-can-i-see-the-stdout-for-processes-in-sweeprolog/6743/2 "2023-07-25T15:41:03Z")

</div>

Of course, just after I posted this question, I found the async query functionality at  
[Sweep: SWI-Prolog Embedded in Emacs](https://eshelyaron.com/sweep.html#async-query), but interestingly the output I get is:

```prolog
starting server on port 8081
Sweep async goal finished

Process ?- server:start. finished

```

The code for `server:start` was:

```prolog
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.

---

<div class="post-metadata">

**Author:** ![meditans](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/meditans/32/1768_2.png) [@meditans](https://swi-prolog.discourse.group/u/meditans)\
**Post date:** [July 25, 2023, 4:37pm UTC](https://swi-prolog.discourse.group/t/how-can-i-see-the-stdout-for-processes-in-sweeprolog/6743/3 "2023-07-25T16:37:14Z")

</div>

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

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

```

instead of

```prolog
    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.

---

<div class="post-metadata">

**Author:** ![oskardrums](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/oskardrums/32/3594_2.png) [@oskardrums](https://swi-prolog.discourse.group/u/oskardrums)\
**Post date:** [July 25, 2023, 6:25pm UTC](https://swi-prolog.discourse.group/t/how-can-i-see-the-stdout-for-processes-in-sweeprolog/6743/4 "2023-07-25T18:25:00Z")

</div>

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

> [@meditans](#):
>
> It seems that the premise of the question was wrong

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:

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

```
