Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are many possibilities. Here's the first one which came to my mind.</p> <p>In Erlang, every process is part of a <em>group</em>. For each group, a process - named <em>group leader</em> gets all the output from the group-mates. The shell process is part of the group <em>init</em>. So, what you could do is to <a href="http://www.erlang.org/doc/man/erlang.html#group_leader-2" rel="nofollow noreferrer">change the <em>group leader</em></a> for the shell process by doing:</p> <pre><code>{ok, Log} = file:open("log", [write]), erlang:group_leader(Log, self()). </code></pre> <p>You might want to create a dedicated process acting as group leader who manages the output in a more clever way. For example, it could wrap the file after a while or when the file reaches a certain size.</p> <p>The problem with this approach is that you have to execute these lines any time you start your shell. Doing it by using the -s flag:</p> <blockquote> <p>erl -s shell_log</p> </blockquote> <p>where shell_log is:</p> <pre><code>-module(shell_log). -export([start/0]). start() -&gt; {ok, Log} = file:open("log", [write]), erlang:group_leader(Log, self()). </code></pre> <p>won't work, because it's still too early (init is still in <code>{starting, started}</code>, as reported by <code>init:get_status()</code>).</p> <p>In the same way, doing it by using the <code>.erlang</code> file in your HOME directory (whose lines are automatically executed every time you start a shell) will fail for a similar reason (init is still in the <code>{starting, applications_loaded}</code> state).</p> <p>Not sure which is the best way to circumvent this problem. I'll think about it.</p> <p>Finally, this question seems a duplicate of <a href="https://stackoverflow.com/questions/2140604/redirect-output-from-erlang-shell-into-a-file">this thread</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload