Lager issue

Andrew Thompson andrew at hijacked.us
Thu Jan 10 13:22:35 EST 2013


On Thu, Jan 10, 2013 at 01:11:18PM -0500, John Kemp wrote:
> Hi,
> 
> I don't usually have issues with lager, but in logging for my application, I feel like I've done all the right things:
> 
> i) Put lager_transform in my rebar config:
> 
> {erl_opts, [debug_info, warnings_as_errors, {parse_transform, lager_transform}]}.
> 
> ii) Lager is started when my app starts, and I know by asking at the console:
> 
> (lilith at 127.0.0.1)3> application:which_applications().
> [{lilith,[],"1"},
>  {lager,"Erlang logging framework","0.9.4"},
>  {crypto,"CRYPTO version 2","2.2"},
>  {sasl,"SASL  CXC 138 11","2.2.1"},
>  {stdlib,"ERTS  CXC 138 10","1.18.3"},
>  {kernel,"ERTS  CXC 138 10","2.15.3"}]
> 
> Then:
> 
> (lilith at 127.0.0.1)4> application:start(lager).
> {error,{already_started,lager}}
> 
> And yet... 
> 
> (lilith at 127.0.0.1)5> lager:info("foo ~s", [bar]).     
> ** exception error: undefined function lager:info/2
> (lilith at 127.0.0.1)6> lager:error("foo ~s", [bar]).
> ** exception error: undefined function lager:error/2
> (lilith at 127.0.0.1)7> lager:warning("foo ~s", [bar]).
> ** exception error: undefined function lager:warning/2
> (lilith at 127.0.0.1)8> lager:info("Hello!").                   
> ** exception error: undefined function lager:info/1
> 
> Can anyone tell me why lager continues to give me 'undef'?
> 
Lager doesn't actually define lager:info/3, the parse transform walks
the AST of the module and replaces any calls to
lager:(debug|info|notice|...) with some different code. So, since you're
calling lager from the shell, the parse transform isn't involved and you
get undef. If you want to log from the shell, you can use use
lager:log(info, self(), "foo ~s", [bar]), or whatever.

Andrew




More information about the riak-users mailing list