From 3119badb2b879e7695f9518592f4edd71a44a5df Mon Sep 17 00:00:00 2001 From: Pablo Polvorin Date: Tue, 24 Feb 2009 03:04:58 +0000 Subject: [PATCH] Removed a couple of expensive function calls used as arguments for ?DEBUG macros. All arguments used in the ?DEBUG macro are strictly evaluated (even if the loglevel is higher). The same is true for all log macros defined in ejabberd.hrl. We might need to use lazy evaluation for the arguments, when they are expensive to generate (wrap the arguments lists in a fun). SVN Revision: 1915 --- ChangeLog | 8 ++++++++ src/ejabberd_c2s.erl | 2 +- src/ejabberd_receiver.erl | 2 +- src/mod_caps.erl | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c1688ad4e..75bb8adc1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,14 @@ sql-escape it. The escaped value returned is allways a list() (ejabberd's odbc drivers only works on lists()) + * src/ejabberd_c2s.erl, src/mod_caps.erl, src/ejabberd_receiver.erl: + Removed a couple of expensive function calls used as arguments for + ?DEBUG macros. All arguments used in the ?DEBUG macro are strictly + evaluated (even if the loglevel is higher). The same is true for + all log macros defined in ejabberd.hrl. We might need to use lazy + evaluation for the arguments, when they are expensive to generate + (wrap the arguments lists in a fun). + 2009-02-23 Christophe Romain * src/ejabberd_c2s.erl: Do not call mod_caps:clear_caps, this previous diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index 50cac7292..614a4e4e4 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -1277,7 +1277,7 @@ change_shaper(StateData, JID) -> (StateData#state.sockmod):change_shaper(StateData#state.socket, Shaper). send_text(StateData, Text) -> - ?DEBUG("Send XML on stream = ~p", [lists:flatten(Text)]), + ?DEBUG("Send XML on stream = ~s", [Text]), (StateData#state.sockmod):send(StateData#state.socket, Text). send_element(StateData, #xmlel{ns = ?NS_XMPP, name = 'stream'} = El) -> diff --git a/src/ejabberd_receiver.erl b/src/ejabberd_receiver.erl index 05f8ddfb6..95e153554 100644 --- a/src/ejabberd_receiver.erl +++ b/src/ejabberd_receiver.erl @@ -302,7 +302,7 @@ process_data(Data, #state{xml_stream_state = XMLStreamState, shaper_state = ShaperState, c2s_pid = C2SPid} = State) -> - ?DEBUG("Received XML on stream = ~p", [binary_to_list(Data)]), + ?DEBUG("Received XML on stream = ~p", [Data]), {ok, XMLStreamState1} = exmpp_xmlstream:parse(XMLStreamState, Data), {NewShaperState, Pause} = shaper:update(ShaperState, size(Data)), HibTimeout = diff --git a/src/mod_caps.erl b/src/mod_caps.erl index c7483a121..df327eadf 100644 --- a/src/mod_caps.erl +++ b/src/mod_caps.erl @@ -311,7 +311,7 @@ handle_cast({disco_response, From, _To, #iq{id = ID, type = Type, payload = Payl %gen_server:cast(self(), visit_feature_queries), %?DEBUG("Error IQ reponse from ~s:~n~p", [exmpp_jid:jid_to_list(From), SubEls]); {result, Payload} -> - ?DEBUG("Invalid IQ contents from ~s:~n~p", [exmpp_jid:jid_to_list(From), Payload]); + ?DEBUG("Invalid IQ contents from ~s:~n~p", [exmpp_jid:jid_to_binary(From), Payload]); _ -> %% Can't do anything about errors ok