anchor.diff:  create_drain(Id, Dict) ->
       case dict_find(<<"ch">>, Dict) of
           undefined ->
  -            io:format("Error ~p ~p ~p ~p ~p~n", [?MODULE, create_drain, missing_ch, Id, dict:to_list(Dict)]);
  +            ?ERR("~p ~p ~p ~p~n",
  +                 [create_drain, missing_ch, Id, dict:to_list(Dict)]);
           Val1 ->
               Ch = list_to_integer(binary_to_list(Val1)),
               case dict_find(<<"token">>, Dict) of
                   undefined ->
  -                    io:format("Error ~p ~p ~p ~p ~p~n", [?MODULE, create_drain, missing_token, Id, dict:to_list(Dict)]);
  +                    ?ERR("~p ~p ~p ~p~n",
  +                         [create_drain, missing_token, Id, dict:to_list(Dict)]);
                   Token ->
                       Host = dict_find(<<"host">>, Dict),
                       Port =
  
positive.code:     T = logplex_utils:empty_token(),
      case ets:match_object(tokens, T#token{channel_id=Drain#drain.channel_id}) of
          [] ->
              io:format("Error ~p ~p ~p ~p~n", [?MODULE, populate_token_drain_data, undefined_tokens, Drain]);
          Tokens ->
              Drain1 = Drain#drain{resolved_host=logplex_utils:resolve_host(Drain#drain.host)},
              ets:insert(tokens, [Token#token{drains=[Drain1|Drains]} || #token{drains=Drains}=Token <- Tokens])
  
negative.code: handle({cmd, "hmset", [<<"ch:", Rest/binary>> | Args]}) ->
      Id = list_to_integer(parse_id(Rest)),
      Dict = dict_from_list(Args),
      ?INFO("event=set type=channel id=~p~n", [Id]),
      create_channel(Id, Dict);
  
  handle({cmd, "hmset", [<<"tok:", Rest/binary>> | Args]}) ->
      Id = list_to_binary(parse_id(Rest)),
      Dict = dict_from_list(Args),
      Token = create_token(Id, Dict),
      ?INFO("event=set type=token id=~p~n", [Id]),
      populate_token_channel_data([Token]);
  
  handle({cmd, "hmset", [<<"drain:", Rest/binary>> | Args]}) ->
      Id = list_to_integer(parse_id(Rest)),
      Dict = dict_from_list(Args),
      Drain = create_drain(Id, Dict),
      ?INFO("event=set type=drain id=~p~n", [Id]),
      Drain#drain.host =/= undefined andalso populate_token_drain_data([Drain]);
  
  handle({cmd, "del", [<<"ch:", Rest/binary>> | _Args]}) ->
      Id = list_to_integer(parse_id(Rest)),
      ?INFO("event=delete type=channel id=~p~n", [Id]),
      ets:delete(channels, Id);
  
  handle({cmd, "del", [<<"tok:", Rest/binary>> | _Args]}) ->
      Id = list_to_binary(parse_id(Rest)),
      ?INFO("event=delete type=token id=~p~n", [Id]),
      ets:delete(tokens, Id);
  
  handle({cmd, "del", [<<"drain:", Rest/binary>> | _Args]}) ->
      Id = list_to_integer(parse_id(Rest)),
      ?INFO("event=delete type=drain id=~p~n", [Id]),
      remove_token_drain_data(Id),
      ets:delete(drains, Id);
  
  