<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Thank you very much for the explanation.<br>
<br>
Regards,<br>
Martin<br>
<br>
<div class="moz-cite-prefix">On 1/21/2016 5:12 PM, Sean Cribbs
wrote:<br>
</div>
<blockquote
cite="mid:CAPGJuCb4m25pHKX51FO38LbrvjaLuC8ZDr283keEp6si7YbQvA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>What the message is telling you is that lager:debug() is
not a function. Indeed, if you read the source of the lager
module, it is not.</div>
<div><br>
</div>
The parse_transform is needed to inject code into the spot where
you call lager:debug() and replace it with real calls. It is
designed this way so as to provide an unsurprising interface to
the developer (logging at specific severity levels), and so that
it can filter out unconsumable log messages at the callsite
rather than filtering them out in the gen_event that receives
the log messages. Essentially, the code injection transforms the
function name ('debug' in this case) into the severity level,
adds some metadata to the message (line, module, pid, etc), and
then does a few checks to verify that the message is loggable.
For instance, it will check whether the log sink process is
running, and that there exists at least one output handler that
is consuming that severity or lower, or that there is an
existing trace that matches. Only *then* will it log the
message.
<div><br>
</div>
<div>I would recommend using rebar3 or similar tools that can
apply the parse_transform across all of your code, instead of
calling erlc directly.<br>
<div><br>
</div>
<div><br>
</div>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Jan 21, 2016 at 8:56 AM, Martin
Koroudjiev <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:mrtndimitrov@gmail.com" target="_blank">mrtndimitrov@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I am trying to include lager into our application but I am
having<br>
problems. I include the lager ebin directory on startup
with: -pa<br>
"../lib/lager-2.0.3/ebin"<br>
Then I start lager with: lager:start().<br>
I define a constant as: -define(dbg(Fmt), lager:debug(Fmt)).<br>
But when I try to use it in the code:<br>
?dbg("Hello").<br>
it says: ** exception error: undefined function
lager:debug/1<br>
<br>
I've checked lager's help page on github and saw that a
parse_transform<br>
must be set to lager_transform. Why is this needed?<br>
<br>
And how to actually do it? I compile my source files with
erlc and pass<br>
the transform option with +"{parse_transform,
lager_transform}" but then<br>
the code doesn't compile because lager_transform module is
not present<br>
at that time.<br>
<br>
Thank you,<br>
Martin<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a moz-do-not-send="true"
href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a moz-do-not-send="true"
href="http://erlang.org/mailman/listinfo/erlang-questions"
rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>