debug\trace
Posted: 11 April 2007 09:42 AM   [ Ignore ]
Newbie
Rank
Total Posts:  27
Joined  2007-04-11

Hello All.

I am newbie in ejabberd.

Now I written my first mod and I want write log to debug/trace.

What is standart way to do this?

Profile
 
 
Posted: 11 April 2007 01:19 PM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  128
Joined  2006-11-12

Hello,

You can include ejabberd.hrl in your module and use macros for that.
Here are the available macros for the development version:

?DEBUG(Format, Args)
?INFO_MSG(Format, Args)
?WARNING_MSG(Format, Args)
?ERROR_MSG(Format, Args)
?CRITICAL_MSG(Format, Args)

The Format and Args are the same time of parameters than io:format/2.

The stable version should only allow debug, info and error.

I hope this helps,

 Signature 

Mickaël Rémond
Process-one

Profile
 
 
Posted: 11 April 2007 01:46 PM   [ Ignore ]   [ # 2 ]
Newbie
Rank
Total Posts:  27
Joined  2007-04-11

I must recompile all ejabber with uncomment line
-define(ejabberd_debug, true).
in ejabberd.hrl file

or

I have to include ejabberd.hrl in only my module?

Where I can see debug\trace messages? What I need run?

PS: I work under Windows.

Profile
 
 
Posted: 13 April 2007 05:40 AM   [ Ignore ]   [ # 3 ]
Newbie
Rank
Total Posts:  3
Joined  2007-04-13

You must include ejabberd.hrl in your module to use these macros.
You only need to uncomment the ‘-define(ejabberd_debug, true)’ if you wish to use ?DEBUG(Format, Args). The other macros are uneffected (note: I’m looking at v1.1.2).

Debug messages will appear in the erl shell.

ERROR_MSG/2 and INFO_MSG/2 uses the error_logger. These can appear in the erl shell or in ejabberd.log.

Profile
 
 
Posted: 13 April 2007 10:24 AM   [ Ignore ]   [ # 4 ]
Newbie
Rank
Total Posts:  27
Joined  2007-04-11

I don’t understand :-(((

I create my mod
---
-module(my).
-behaviour(gen_mod).
-export([start/2, stop/1]).
-include("ejabberd.hrl").

start(_Host, _Opts) -> ?INFO_MSG("Here i am start!!!!”, []).
stop(_Host) -> ?INFO_MSG("Here i am stop!!!!”, []).
---

compile this file
erlc my.erl

and move my.beam into
“C:\Program Files\ejabberd-1.1.3\lib\ejabberd-1.1.3\ebin\”

edit “C:\Program Files\ejabberd-1.1.3\conf\ejabberd.cfg”
---
...
% Used modules:
{modules,
[
...
{my, []},
...
...
---

start ejabberd, and debug after

bash ejabberdctl start
bash ejabberdctl debug

(after that I see http://vinnitu.dyndns.org/images/2007-04-13_115210.jpg )

but module not loaded because it is absent in list modules, why?

is my code incorrect?

Profile
 
 
Posted: 17 April 2007 01:42 PM   [ Ignore ]   [ # 5 ]
Newbie
Rank
Total Posts:  3
Joined  2007-04-13

As a quick note I would suggest starting from either mod_echo, mod_time or mod_version as these 3 represent very simple plugins.

Profile
 
 
Posted: 17 April 2007 02:40 PM   [ Ignore ]   [ # 6 ]
Newbie
Rank
Total Posts:  27
Joined  2007-04-11

so…
what I must to do to see debug messages in erl console?…

Profile
 
 
Posted: 26 April 2007 02:26 PM   [ Ignore ]   [ # 7 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  128
Joined  2006-11-12

Depending on your configuration, the log messages will either go in the console. You can always see them in the ejabberd.log file.

 Signature 

Mickaël Rémond
Process-one

Profile
 
 
   
 
 
‹‹ svn site down?      Ejabberd ››