4

I have added Lager to my application using rebar. It compiles fine and Lager starts ok when I start my app. However, I get undef messages when I call lager:debug/1 which tells me that the lager_transform parse transformation is not being picked up, but I have added the following to my rebar.config:

{erl_opts, [{parse_transform, lager_transform}]}.

and I am of course compiling with rebar.

Myles McDonnell
  • 12,943
  • 17
  • 66
  • 116
  • 1
    Have you seen https://github.com/basho/lager/issues/60#issuecomment-7583150 ? – André Laszlo Feb 06 '15 at 13:11
  • 1
    I have now, thanks. Adding the -compile([{parse_transform, lager_transform}]). to each module where I need the transforms has resolved my issue. But, the https://github.com/basho/lager page says this is an alternative to setting the compiler flags, which I have done via rebar.config, assuming this would make the transforms available through the module. Obviously there is something I don't understand going on here. – Myles McDonnell Feb 06 '15 at 13:28
  • You should be able to compile all the files with the `{parse_transform, lager_transform}` option without having the compile flag set in every file. I use erlang.mk and it makes this trivial. I don't know enough about rebar to know why erl_opts isn't working. – Stratus3D Feb 06 '15 at 13:49
  • 2
    The following absolutely works with rebar {erl_opts, [{parse_transform, lager_transform}]}. I use it on Mac OSX, Windows, Ubuntu and have for years. Did you do a rebar clean before re-compiling to ensure that all of your beam's had the transform applied? – Jr0 Feb 06 '15 at 16:12
  • @Jr0 seems that was the issue, thanks,\ – Myles McDonnell Feb 06 '15 at 16:49

1 Answers1

1

try add into your module

-compile({parse_transform, lager_transform}).

and show rebar.config and your code