From: Jérôme Sautret Date: Mon, 13 Oct 2008 15:29:05 +0000 (+0000) Subject: * src/odbc/ejabberd_odbc.erl: log MySQL driver messages (merge 1652 from trunk). X-Git-Tag: v2.0.3~49 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=184251b162db72bf917ffed8361bda3a5c925bdd;p=ejabberd * src/odbc/ejabberd_odbc.erl: log MySQL driver messages (merge 1652 from trunk). SVN Revision: 1653 --- diff --git a/ChangeLog b/ChangeLog index 8b55a35aa..4c9be11e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-10-13 Jerome Sautret + + * src/odbc/ejabberd_odbc.erl: log MySQL driver messages. + 2008-10-07 Jerome Sautret * src/mod_roster_odbc.erl: fix MySQL multiple requests issue. diff --git a/src/odbc/ejabberd_odbc.erl b/src/odbc/ejabberd_odbc.erl index 4921fdb63..c270dd67c 100644 --- a/src/odbc/ejabberd_odbc.erl +++ b/src/odbc/ejabberd_odbc.erl @@ -304,8 +304,7 @@ pgsql_item_to_odbc(_) -> %% part of init/1 %% Open a database connection to MySQL mysql_connect(Server, Port, DB, Username, Password, StartInterval) -> - NoLogFun = fun(_Level,_Format,_Argument) -> ok end, - case mysql_conn:start(Server, Port, Username, Password, DB, NoLogFun) of + case mysql_conn:start(Server, Port, Username, Password, DB, fun log/3) of {ok, Ref} -> erlang:monitor(process, Ref), mysql_conn:fetch(Ref, ["set names 'utf8';"], self()), @@ -340,3 +339,14 @@ mysql_item_to_odbc(Columns, Recs) -> % perform a harmless query on all opened connexions to avoid connexion close. keep_alive(PID) -> gen_server:call(PID, {sql_query, ?KEEPALIVE_QUERY}, 60000). + +% log function used by MySQL driver +log(Level, Format, Args) -> + case Level of + debug -> + ?DEBUG(Format, Args); + normal -> + ?INFO_MSG(Format, Args); + error -> + ?ERROR_MSG(Format, Args) + end.