25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Use error_logger directly in the LDAP test server

This commit is contained in:
Evgeniy Khramtsov 2013-07-07 03:47:44 +10:00
parent a302af7770
commit 2b24e97936

View File

@ -22,9 +22,11 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]). terminate/2, code_change/3]).
-include("logger.hrl").
-include("ELDAPv3.hrl"). -include("ELDAPv3.hrl").
-define(INFO_MSG(Fmt, Args), error_logger:info_msg(Fmt, Args)).
-define(ERROR_MSG(Fmt, Args), error_logger:error_msg(Fmt, Args)).
-define(TCP_SEND_TIMEOUT, 32000). -define(TCP_SEND_TIMEOUT, 32000).
-define(SERVER, ?MODULE). -define(SERVER, ?MODULE).
@ -75,8 +77,8 @@ handle_cast(_Msg, State) ->
handle_info({'DOWN', MRef, _Type, _Object, Info}, handle_info({'DOWN', MRef, _Type, _Object, Info},
#state{listener = MRef} = State) -> #state{listener = MRef} = State) ->
?CRITICAL_MSG("listener died with reason ~p, terminating", ?ERROR_MSG("listener died with reason ~p, terminating",
[Info]), [Info]),
{stop, normal, State}; {stop, normal, State};
handle_info(_Info, State) -> handle_info(_Info, State) ->
{noreply, State}. {noreply, State}.
@ -111,7 +113,7 @@ process(Socket, Tree) ->
fun(ReplyOp) -> fun(ReplyOp) ->
Reply = #'LDAPMessage'{messageID = Id, Reply = #'LDAPMessage'{messageID = Id,
protocolOp = ReplyOp}, protocolOp = ReplyOp},
?DEBUG("sent:~n~p", [Reply]), %%?DEBUG("sent:~n~p", [Reply]),
{ok, Bytes} = asn1rt:encode( {ok, Bytes} = asn1rt:encode(
'ELDAPv3', 'LDAPMessage', Reply), 'ELDAPv3', 'LDAPMessage', Reply),
gen_tcp:send(Socket, Bytes) gen_tcp:send(Socket, Bytes)
@ -125,8 +127,8 @@ process(Socket, Tree) ->
Err Err
end. end.
process_msg(#'LDAPMessage'{protocolOp = Op} = Msg, TopTree) -> process_msg(#'LDAPMessage'{protocolOp = Op} = _Msg, TopTree) ->
?DEBUG("got:~n~p", [Msg]), %%?DEBUG("got:~n~p", [Msg]),
case Op of case Op of
{bindRequest, {bindRequest,
#'BindRequest'{name = DN}} -> #'BindRequest'{name = DN}} ->