Problem using lager

Hi.

Im trying to write a module for ejabberd but whe I add it I get de next error:

2013-12-02 15:28:24.196 [critical] <0.37.0>@gen_mod:start_module:78 Problem starting the module mod_mymod for host <<"XYZ">>
options: []
error: undef
[{p1_logger,info_msg,
[mod_mymod,28,"Iniciando modulo mymod",[]],
[]},
{mod_mymod,start,2,[{file,"src/mod_mymod.erl"},{line,28}]},
{gen_mod,start_module,3,[{file,"src/gen_mod.erl"},{line,70}]},
{lists,foreach,2,[{file,"lists.erl"},{line,1262}]},
{ejabberd_app,start,2,[{file,"src/ejabberd_app.erl"},{line,67}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},{line,274}]}]
2013-12-02 15:28:24.196 [critical] <0.37.0>@gen_mod:start_module:83 ejabberd initialization was aborted because a module start failed.

I don't have p1_logger because i want to use lager but lager don't initiate and the logger try tu use p1_logger instead lager

The questions are, how can I initialize lager. Should I need extra configuration o how should i compile my mod?

I tried on compile including {parse_transform, lager_transform}, and tried including the line into the mod but no success.

This is part of my erl file

-module(mod_mymod).
-behaviour(gen_mod).
-export([start/2,
init/2,
stop/1,
send_notice/3]).

-define(PROCNAME, ?MODULE).
-compile([{parse_transform, lager_transform}]).

-include("ejabberd.hrl").
-include("logger.hrl").
-include("jlib.hrl").

start(Host, Opts) ->
?INFO_MSG("Iniciando modulo", []),
ok.

init(Host, _Opts) ->
?INFO_MSG("En init", [] ),
ok.

stop(Host) ->
?INFO_MSG("Deteniendo modulo", [] ),
ok.

Thanks a lot and sorry by my poor English.

I've had the same problem,

I've had the same problem, but just want to use any logger to rid off of that error.

So i've found a solution:

1) You need to use full source code of ejabberd downloaded from github for example.
2) Put your mod's .erl files into src/ directory of ejabberd source tree, you've just downloaded.
3) run ./configure from the root directory of source code tree.
4) run make from same root dir.
5) you'll get your mod's beam files in source tree ebin/ directory.
6) Your mod will use p1_logger, now.

But for all of this to work you'll need all software/libraries for building full ejabberd installation:
https://github.com/processone/ejabberd/blob/master/README

Hi. Thanks for your answer. I

Hi.

Thanks for your answer.

I solve it including in my modules the lager.hrl and into that file I add the line
-define(LAGER,1)

But before this I ensure that ejabber is running with lager support.

Now my mods use lager for logs.

Thanks again.

Syndicate content