anchor.diff:      {reply, Reply, State}.
   
   % Inbound logging request.
  -handle_cast({log, Module, Code, Fmt, Args}, State) ->
  +handle_cast({log, Module, Code, Fmt, Args}, State = #state{dedup=Dedup}) ->
  +    Now = erlang:now(),
  +    Key = {Module, Code, Fmt, Args},
  +    case dict:find(Key, Dedup) of
  +    {ok, {Count, FirstSeen, LastSeen}} ->
  +        error_logger:info_msg("ns_log: suppressing duplicate log ~p:~p(~p) because it's been "
  +                           "seen ~p times in the past ~p secs (last seen ~p secs ago~n",
  +                           [Module, Code, lists:flatten(io_lib:format(Fmt, Args)),
  +                            Count+1, timer:now_diff(Now, FirstSeen) / 1000000,
  +                            timer:now_diff(Now, LastSeen) / 1000000]),
  +        Dedup2 = dict:store(Key, {Count+1, FirstSeen, Now}, Dedup),
  +        {noreply, State#state{dedup=Dedup2}};
  +    error ->
  +        State2 = do_log(Module, Code, Fmt, Args, State),
  +        Dedup2 = dict:store(Key, {0, Now, Now}, Dedup),
  +        {noreply, State2#state{dedup=Dedup2}}
  +    end;
  +handle_cast(clear, _State) ->
  +    error_logger:info_msg("Clearing log.~n", []),
  +    {noreply,  #state{recent=emptyRecent(), dedup=dict:new()}}.
  +% Not handling any other state.
  +
  +% Nothing special.
  +handle_info(garbage_collect, State) ->
  +    {noreply, gc(State)};
  +handle_info(_Info, State) ->
  +    {noreply, State}.
  +
  +terminate(_Reason, _State) ->
  +    ok.
  +
  +code_change(_OldVsn, State, _Extra) ->
  +    {ok, State}.
  +
  +%%--------------------------------------------------------------------
  +%%% Internal functions
  +%%--------------------------------------------------------------------
  +
  +do_log(Module, Code, Fmt, Args, State) ->
       Category = categorize(Module, Code),
       NR = ringbuffer:add(#log_entry{module=Module, code=Code, msg=Fmt, args=Args,
                                      cat=Category,
  
positive.code:     try gen_event:notify(ns_log_events, {ns_log, Category, Module, Code,
                           Fmt, Args})
      catch _:Reason ->
          error_logger:info_msg("ns_log: message: ~p, ~p, ~p, ~p~n",
                                [Module, Code, Fmt, Args])
      end,
      {noreply, State#state{recent=NR}};
  handle_cast(clear, _State) ->
      error_logger:info_msg("Clearing log.~n", []),
      {noreply,  #state{recent=emptyRecent()}}.
  % Not handling any other state.
  
  % Nothing special.
  handle_info(_Info, State) ->
      {noreply, State}.
  
  terminate(_Reason, _State) ->
      ok.
  
  code_change(_OldVsn, State, _Extra) ->
      {ok, State}.
  
  %%--------------------------------------------------------------------
  %%% Internal functions
  %%--------------------------------------------------------------------
  
  %% API
  
  
negative.code: 
  -include_lib("eunit/include/eunit.hrl").
  
  -record(state, {recent, dedup}).
  
  start_link() ->
      Result = gen_server:start_link({global, ?MODULE}, ?MODULE, [], []),
  