May be I missed some, but it works for me in R11B-5<br><br>-module(temp).<br>-export([test/0]).<br>-define(log(Message, Var), log_message(?MODULE, ?LINE, Message, ??Var, Var)).<br><br><br><br>log_message(Module, Line, Message, VarName, Var) -><br>
io:format("log: {~p, ~p} ~s ~s = ~p~n", [Module, Line, Message,<br> VarName, Var]).<br><br>test() -> <br> X = {a,b},<br> ?log("Unexpected post", X). % here is line 20<br><br>
%end<br><br>$ erl -smp<br>Erlang (BEAM) emulator version 5.5.5 [source] [smp:1] [async-threads:0] [hipe] [kernel-poll:false]<br><br>Eshell V5.5.5 (abort with ^G)<br>1> c(temp).<br>{ok,temp}<br>2> temp:test().<br>log: {temp, 20} Unexpected post X = {a,b}<br>
ok<br>3> <br><br><br><div class="gmail_quote">On Wed, Mar 12, 2008 at 4:08 PM, Richard Kelsall <<a href="mailto:r.kelsall@millstream.com">r.kelsall@millstream.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Nohl Attila Rajmund wrote:<br>
> Yes, erlang has excellent trace facilities, it shows me that the 'rfmm'<br>
> function was called - unfortunately it doesn't show that which of the 10<br>
> rfmm functions was called.<br>
<br>
Breaking a small subject off the main thread. I haven't written much<br>
Erlang yet so maybe I'm just missing something, but I get the impression<br>
Erlang won't tell me the line number when something goes wrong. I feel<br>
it would be useful to know this and very in keeping with the Erlang<br>
approach of making bugs nice and visible. So my vote while we're all<br>
requesting changes to Erlang :) is for more line number visibility.<br>
<br>
On a related subject I've played around with the LINE macro to tag<br>
my own logging/error messages with line numbers and the best I could<br>
produce was something like this :<br>
<br>
-define(log(Line, Message, Var), log_message(?MODULE, Line, Message,<br>
??Var, Var)). % LINE macro always gives '1' if I put it here.<br>
<br>
log_message(Module, Line, Message, VarName, Var) -><br>
io:format("log: {~p, ~p} ~s ~s = ~p~n", [Module, Line, Message,<br>
VarName, Var]).<br>
<br>
and then in my code I can do things like<br>
<br>
?log(?LINE, "Unexpected post", Other),<br>
<br>
This works fine, but it would be nice to just write<br>
<br>
?log("Unexpected post", Other),<br>
<br>
and get the line number somehow. Can this be done?<br>
<br>
<br>
Richard.<br>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>--Hynek (Pichi) Vychodil