anchor.diff:                          ok ->
                               vmq_hook:all(on_register, [Peer, ClientId, User, Password]),
                               check_will(F, State#state{username=User});
  -                        {error, _Reason} ->
  +                        {error, Reason} ->
  +                            lager:error("can't register client ~p due to ", [ClientId, Reason]),
                               {connection_attempted,
                                send_connack(?CONNACK_SERVER, State)}
                       end;
                   not_found ->
                       % returned when no hook on_register hook was
                       % able to authenticate user
  +                    lager:error("can't authenticate client ~p due to not_found", [ClientId]),
                       {connection_attempted,
                        send_connack(?CONNACK_AUTH, State)};
                   {error, invalid_credentials} ->
  +                    lager:error("can't authenticate client ~p due to invalid_credentials", [ClientId]),
                       {connection_attempted,
                        send_connack(?CONNACK_CREDENTIALS, State)};
                   {error, not_authorized} ->
  +                    lager:error("can't authenticate client ~p due to not_authorized", [ClientId]),
                       {connection_attempted,
                        send_connack(?CONNACK_AUTH, State)}
               end;
  
positive.code:         true ->
              check_user(F, State#state{client_id=Id});
          false ->
              {connection_attempted,
               send_connack(?CONNACK_PROTO_VER, State)}
      end;
  check_client_id(_, State) ->
      {connection_attempted,
       send_connack(?CONNACK_INVALID_ID, State)}.
  
  
negative.code:         ok ->
              vmq_hook:all(on_register, [Peer, ClientId, undefined, undefined]),
              check_will(F, State#state{clean_session=CleanSession});
          {error, Reason} ->
              lager:error("can't register client ~p due to ~p", [ClientId, Reason]),
              {connection_attempted,
               send_connack(?CONNACK_SERVER, State)}
      end;
  