anchor.diff:           terminate/2,
            code_change/3]).
   
  --record(state, {sock, buffer = <<>>}).
  +-record(state, {sock :: 'undefined' | port(),
  +                buffer = syslog_parser:new(),
  +                peername :: 'undefined' | {inet:ip4_address(),
  +                                           inet:port_number()}
  +               }).
  +
  +-include("logplex_logging.hrl").
   
   %%====================================================================
   %% API functions
  
positive.code:     logplex_realtime:incr(message_received),
      logplex_queue:in(logplex_work_queue, Msg);
  process_msg({malformed, Msg}) ->
      io:format("[~p] malformed_syslog_message=\"~p\"~n",
                [?MODULE, Msg]),
      logplex_stats:incr(message_received_malformed).
  
negative.code:     inet:setopts(Sock, [{active, once}]),
      {noreply, State#state{buffer=NewBuf}};
  
  handle_info({tcp_closed, Sock}, State = #state{sock = Sock}) ->
      {stop, normal, State};
  
  handle_info({tcp_error, Sock, Reason},
              State = #state{sock = Sock,
                             peername = {H,P}}) ->
      ?WARN("err=gen_tcp peer=~s data=~p",
            [loglex_logging:dest(H,P), Reason]),
      {stop, normal, State};
  
  handle_info(Msg, State) ->
      ?WARN("err=unexpected_cast data=~p", [Msg]),
      {noreply, State}.
  
  terminate(shutdown, _State) ->
  