anchor.diff:      end,
       Port.
   
  -log_messages(Name, L) ->
  +log_messages(L, State) ->
  +    State1 = State#state{messages=ringbuffer:add(hd(L), State#state.messages)},
       receive
           {_Port, {data, Msg}} ->
  -            log_messages(Name, [Msg|L])
  +            log_messages([Msg|L], State1)
       after 0 ->
  -            split_log(Name, L, [])
  +            split_log(State1#state.name, L, []),
  +            State1
       end.
   
   split_log(Name, L, M) ->
  
positive.code: 
  init({Name, _Cmd, _Args, _Opts} = Params) ->
      Port = open_port(Params),
      {ok, #state{port = Port, name = Name}}.
  
  handle_info({_Port, {data, Msg}}, State) ->
      log_messages(State#state.name, [Msg]),
      {noreply, State};
  handle_info({_Port, {exit_status, 0}}, State) ->
      {stop, normal, State};
  handle_info({_Port, {exit_status, Status}}, State) ->
      ns_log:log(?MODULE, ?ABNORMAL,
                 "Port server ~p exited with status ~p. Restarting.~n",
                 [State#state.name, Status]),
      {stop, {abnormal, Status}, State}.
  
  handle_call(unhandled, unhandled, unhandled) ->
  
negative.code: -define(ABNORMAL, 0).
  
  -behavior(gen_server).
  
  -include("ns_common.hrl").
  
  