anchor.diff:              Port ! {self(), {command, Data}}
       end,
       Port.
  -
  -%% @doc Split the log into <64k chunks. The lines are fed in backwards.
  -split_log(L) ->
  -    split_log(L, [], 0).
  -
  -split_log([H|T] = L, M, N) ->
  -    NewLength = N + lists:flatlength(H),
  -    if NewLength > 65000 ->
  -            error_logger:info_msg(lists:flatten(M)),
  -            split_log(L);
  -       true ->
  -            split_log(T, [H|M], NewLength)
  -    end;
  -split_log([], M, _) ->
  -    error_logger:info_msg(lists:flatten(M)).
  
positive.code: 
  %% Internal functions
  
  format_lines(Name, Lines) ->
      Prefix = io_lib:format("~p~p: ", [Name, self()]),
      [[Prefix, Line, $\n] || Line <- Lines].
  
  log_messages(L, State) ->
      State1 = State#state{messages=ringbuffer:add(hd(L), State#state.messages)},
      receive
          {_Port, {data, {_, Msg}}} ->
              log_messages([Msg|L], State1)
      after 0 ->
              %% split_log will reverse the lines
              split_log(format_lines(State#state.name, L)),
              State1
      end.
  
  open_port({_Name, Cmd, Args, OptsIn}) ->
      %% Incoming options override existing ones (specified in proplists docs)
  
negative.code:                 messages = ringbuffer:new(?NUM_MESSAGES)}}.
  
  handle_info({_Port, {data, {_, Msg}}}, State) ->
      {Msgs, Dropped} = fetch_messages(99, 1000),
      L = [Msg|Msgs],
      %% Store the last messages in case of a crash
      Messages = lists:foldl(fun ringbuffer:add/2, State#state.messages, L),
      error_logger:info_msg(format_lines(State#state.name, L)),
      if Dropped > 0 ->
              ?log_warning("Dropped ~p log lines from ~p",
                           [Dropped, State#state.name]);
         true ->
              ok
      end,
      {noreply, State#state{messages=Messages}};
  handle_info({_Port, {exit_status, 0}}, State) ->
      {stop, normal, State};
  handle_info({_Port, {exit_status, Status}}, State) ->
  