Always got undef lager_transform error when using lager log framework

I want to use lager as my logging utility, and I have orgnazied my proj as shown below:

proj\ | |--lager\ | |--src\ | |--ebin\ | |--... | |--logserver\ | |--src\ | |--ebin\ | |--rebar.config | |--... | |--rebar | 

However, when I try to compile logserver, I always get the following error:

D: \ proj \ logserver> .. \ rebar compile

 ==> logserver (compile) src/logserver_app.erl:none: error in parse transform 'lager_transform': {undef, [{lager_transform, parse_transform, [[{attribute,1,file, {"src/logserver_app.erl",1}}, ... 

Can anyone know the reason? Thanks!

This is additional information:

  • I use Windows and use the latest Erlang version and armature and lager.
  • lager itself is already compiled. We can find the file D: \ proj \ logserver> dir .. \ lager \ ebin \ lager_transform.beam (this will succeed)
  • reinforcement configuration file (D: \ proj \ logserver \ rebar.config):

    ... {erl_opts, [{parse_transform, lager_transform}, debug_info, {d, 'TEST'}, {i, "include"}, {src_dirs, ["src"]}]}.

    {lib_dirs, [".. \ lager \ ebin"]} ....

+4
source share
2 answers

If you already have lager in your folders, make sure you first move the lager dependency in the rebar.config file so that it compiles first.

+5
source

Have you added lager as a dependency in rebar.config ? I think lager is not on the way.

From the rebar wiki :

To use lager in your application, you need to define it as an armature or have another way to include it in the erlangs path. Then you can add the following parameter to the erlang compiler flags:

 {parse_transform, lager_transform} 

You can add 'lager' as a dependency by editing your rebar.config :

 %% == Dependencies == %% Where to put any downloaded dependencies. Default is "deps" {deps_dir, "deps"}. %% What dependencies we have, dependencies can be of 3 forms, an application %% name as an atom, eg. mochiweb, a name and a version (from the .app file), or %% an application name, a version and the SCM details on how to fetch it (SCM %% type, location and revision). Rebar currently supports git, hg, bzr and svn. {deps, [application_name, {application_name, "1.0.*"}, {application_name, "1.0.*", {git, "git://github.com/basho/rebar.git", {branch, "master"}}}]}. 

In your case, it should be something like this:

 {deps, [{lager, ".*", {git, "git://github.com/basho/lager.git", "HEAD"}}]}. 

More information about the dependency manager in rebar:

https://github.com/basho/rebar/wiki/Dependency-management

+3
source

Source: https://habr.com/ru/post/1433110/


All Articles