[ http://www.erlang.org/pipermail/erlang-questions/2008-March/033647.html ] Nohl Attila Rajmund wrote: > Yes, erlang has excellent trace facilities, it shows me that the 'rfmm' > function was called - unfortunately it doesn't show that which of the 10 > rfmm functions was called. Breaking a small subject off the main thread. I haven't written much Erlang yet so maybe I'm just missing something, but I get the impression Erlang won't tell me the line number when something goes wrong. I feel it would be useful to know this and very in keeping with the Erlang approach of making bugs nice and visible. So my vote while we're all requesting changes to Erlang :) is for more line number visibility. On a related subject I've played around with the LINE macro to tag my own logging/error messages with line numbers and the best I could produce was something like this : -define(log(Line, Message, Var), log_message(?MODULE, Line, Message, ??Var, Var)). % LINE macro always gives '1' if I put it here. log_message(Module, Line, Message, VarName, Var) -> io:format("log: {~p, ~p} ~s ~s = ~p~n", [Module, Line, Message, VarName, Var]). and then in my code I can do things like ?log(?LINE, "Unexpected post", Other), This works fine, but it would be nice to just write ?log("Unexpected post", Other), and get the line number somehow. Can this be done? Richard. _______________________________________________ erlang-questions mailing list erlang-questions@erlang.org http://www.erlang.org/mailman/listinfo/erlang-questions Reply Reply to all Forward Eider Silva de Oliveira to Richard, Erlang, Nohl show details 6:47 PM (21 hours ago) Reply I use this: -define(d(Format, Args), io:format("~s" ++ Format, [string:left(lists:flatten(io_lib:format("~p~p(~p):", [self(),? MODULE, ?LINE])), 35, $ ) | Args])). - Show quoted text - On 12/03/2008, at 12:08, Richard Kelsall wrote: > Nohl Attila Rajmund wrote: >> Yes, erlang has excellent trace facilities, it shows me that the >> 'rfmm' >> function was called - unfortunately it doesn't show that which of >> the 10 >> rfmm functions was called. > > Breaking a small subject off the main thread. I haven't written much > Erlang yet so maybe I'm just missing something, but I get the > impression > Erlang won't tell me the line number when something goes wrong. I feel > it would be useful to know this and very in keeping with the Erlang > approach of making bugs nice and visible. So my vote while we're all > requesting changes to Erlang :) is for more line number visibility. > > On a related subject I've played around with the LINE macro to tag > my own logging/error messages with line numbers and the best I could > produce was something like this : > > -define(log(Line, Message, Var), log_message(?MODULE, Line, Message, > ??Var, Var)). % LINE macro always gives '1' if I put it > here. > > log_message(Module, Line, Message, VarName, Var) -> > io:format("log: {~p, ~p} ~s ~s = ~p~n", [Module, Line, Message, > VarName, Var]). > > and then in my code I can do things like > > ?log(?LINE, "Unexpected post", Other), > > This works fine, but it would be nice to just write > > ?log("Unexpected post", Other), > > and get the line number somehow. Can this be done? > > > Richard. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@erlang.org > http://www.erlang.org/mailman/listinfo/erlang-questions _______________________________________________ erlang-questions mailing list erlang-questions@erlang.org http://www.erlang.org/mailman/listinfo/erlang-questions Reply Reply to all Forward Richard Kelsall to Eider, Erlang, Nohl show details 7:44 PM (20 hours ago) Reply Thank you. That looks good. I'll experiment with it. - Show quoted text - Eider Silva de Oliveira wrote: > I use this: > > -define(d(Format, Args), > io:format("~s" ++ Format, > [string:left(lists:flatten(io_lib:format("~p~p(~p):", [self(),?MODULE, > ?LINE])), 35, $ ) | Args])). > > > On 12/03/2008, at 12:08, Richard Kelsall wrote: > >> Nohl Attila Rajmund wrote: >>> Yes, erlang has excellent trace facilities, it shows me that the 'rfmm' >>> function was called - unfortunately it doesn't show that which of the 10 >>> rfmm functions was called. >> >> Breaking a small subject off the main thread. I haven't written much >> Erlang yet so maybe I'm just missing something, but I get the impression >> Erlang won't tell me the line number when something goes wrong. I feel >> it would be useful to know this and very in keeping with the Erlang >> approach of making bugs nice and visible. So my vote while we're all >> requesting changes to Erlang :) is for more line number visibility. >> >> On a related subject I've played around with the LINE macro to tag >> my own logging/error messages with line numbers and the best I could >> produce was something like this : >> >> -define(log(Line, Message, Var), log_message(?MODULE, Line, Message, >> ??Var, Var)). % LINE macro always gives '1' if I put it here. >> >> log_message(Module, Line, Message, VarName, Var) -> >> io:format("log: {~p, ~p} ~s ~s = ~p~n", [Module, Line, Message, >> VarName, Var]). >> >> and then in my code I can do things like >> >> ?log(?LINE, "Unexpected post", Other), >> >> This works fine, but it would be nice to just write >> >> ?log("Unexpected post", Other), >> >> and get the line number somehow. Can this be done? >> - Show quoted text - _______________________________________________ erlang-questions mailing list erlang-questions@erlang.org http://www.erlang.org/mailman/listinfo/erlang-questions Reply Reply to all Forward Eider Silva de Oliveira to Richard, Erlang, Nohl show details 8:09 PM (20 hours ago) Reply I've found it in the mnesia example code! You'd find a lot of hints in the original source code. - Show quoted text - On 12/03/2008, at 14:44, Richard Kelsall wrote: > Thank you. That looks good. I'll experiment with it. > > Eider Silva de Oliveira wrote: >> I use this: >> -define(d(Format, Args), >> io:format("~s" ++ Format, >> [string:left(lists:flatten(io_lib:format("~p~p(~p):", [self(),? >> MODULE, ?LINE])), 35, $ ) | Args])). >> On 12/03/2008, at 12:08, Richard Kelsall wrote: >>> Nohl Attila Rajmund wrote: >>>> Yes, erlang has excellent trace facilities, it shows me that the >>>> 'rfmm' >>>> function was called - unfortunately it doesn't show that which of >>>> the 10 >>>> rfmm functions was called. >>> >>> Breaking a small subject off the main thread. I haven't written much >>> Erlang yet so maybe I'm just missing something, but I get the >>> impression >>> Erlang won't tell me the line number when something goes wrong. I >>> feel >>> it would be useful to know this and very in keeping with the Erlang >>> approach of making bugs nice and visible. So my vote while we're all >>> requesting changes to Erlang :) is for more line number visibility. >>> >>> On a related subject I've played around with the LINE macro to tag >>> my own logging/error messages with line numbers and the best I could >>> produce was something like this : >>> >>> -define(log(Line, Message, Var), log_message(?MODULE, Line, >>> Message, >>> ??Var, Var)). % LINE macro always gives '1' if I put it >>> here. >>> >>> log_message(Module, Line, Message, VarName, Var) -> >>> io:format("log: {~p, ~p} ~s ~s = ~p~n", [Module, Line, Message, >>> VarName, Var]). >>> >>> and then in my code I can do things like >>> >>> ?log(?LINE, "Unexpected post", Other), >>> >>> This works fine, but it would be nice to just write >>> >>> ?log("Unexpected post", Other), >>> >>> and get the line number somehow. Can this be done? >>> > _______________________________________________ erlang-questions mailing list erlang-questions@erlang.org http://www.erlang.org/mailman/listinfo/erlang-questions Reply Reply to all Forward Hynek Vychodil to Richard, Erlang, Nohl show details 10:35 PM (17 hours ago) Reply May be I missed some, but it works for me in R11B-5 -module(temp). -export([test/0]). -define(log(Message, Var), log_message(?MODULE, ?LINE, Message, ??Var, Var)). log_message(Module, Line, Message, VarName, Var) -> io:format("log: {~p, ~p} ~s ~s = ~p~n", [Module, Line, Message, VarName, Var]). test() -> X = {a,b}, ?log("Unexpected post", X). % here is line 20 %end $ erl -smp Erlang (BEAM) emulator version 5.5.5 [source] [smp:1] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.5.5 (abort with ^G) 1> c(temp). {ok,temp} 2> temp:test(). log: {temp, 20} Unexpected post X = {a,b} ok 3> - Show quoted text - On Wed, Mar 12, 2008 at 4:08 PM, Richard Kelsall wrote: Nohl Attila Rajmund wrote: > Yes, erlang has excellent trace facilities, it shows me that the 'rfmm' > function was called - unfortunately it doesn't show that which of the 10 > rfmm functions was called. Breaking a small subject off the main thread. I haven't written much Erlang yet so maybe I'm just missing something, but I get the impression Erlang won't tell me the line number when something goes wrong. I feel it would be useful to know this and very in keeping with the Erlang approach of making bugs nice and visible. So my vote while we're all requesting changes to Erlang :) is for more line number visibility. On a related subject I've played around with the LINE macro to tag my own logging/error messages with line numbers and the best I could produce was something like this : -define(log(Line, Message, Var), log_message(?MODULE, Line, Message, ??Var, Var)). % LINE macro always gives '1' if I put it here. log_message(Module, Line, Message, VarName, Var) -> io:format("log: {~p, ~p} ~s ~s = ~p~n", [Module, Line, Message, VarName, Var]). and then in my code I can do things like ?log(?LINE, "Unexpected post", Other), This works fine, but it would be nice to just write ?log("Unexpected post", Other), and get the line number somehow. Can this be done? Richard. _______________________________________________ erlang-questions mailing list erlang-questions@erlang.org http://www.erlang.org/mailman/listinfo/erlang-questions -- --Hynek (Pichi) Vychodil _______________________________________________ erlang-questions mailing list erlang-questions@erlang.org http://www.erlang.org/mailman/listinfo/erlang-questions Reply Reply to all Forward Richard Kelsall to Hynek, Erlang, Attila.Rajmund. show details 3:58 PM (29 minutes ago) Reply Gah, indeed it does work, more egg on face :) I went through several versions to get to that point, I must have tried substituting ?LINE into a previous version and failed somehow. Thank you. Richard. Hynek Vychodil wrote: > May be I missed some, but it works for me in R11B-5 > > -module(temp). > -export([test/0]). > -define(log(Message, Var), log_message(?MODULE, ?LINE, Message, ??Var, > Var)). > > > > log_message(Module, Line, Message, VarName, Var) -> > io:format("log: {~p, ~p} ~s ~s = ~p~n", [Module, Line, Message, > VarName, Var]). > > test() -> > X = {a,b}, > ?log("Unexpected post", X). % here is line 20 > > %end > > $ erl -smp > Erlang (BEAM) emulator version 5.5.5 [source] [smp:1] [async-threads:0] > [hipe] [kernel-poll:false] > > Eshell V5.5.5 (abort with ^G) > 1> c(temp). > {ok,temp} > 2> temp:test(). > log: {temp, 20} Unexpected post X = {a,b} > ok > 3> > > > On Wed, Mar 12, 2008 at 4:08 PM, Richard Kelsall - Show quoted text - > > wrote: > > Nohl Attila Rajmund wrote: > > Yes, erlang has excellent trace facilities, it shows me that the > 'rfmm' > > function was called - unfortunately it doesn't show that which of > the 10 > > rfmm functions was called. > > Breaking a small subject off the main thread. I haven't written much > Erlang yet so maybe I'm just missing something, but I get the impression > Erlang won't tell me the line number when something goes wrong. I feel > it would be useful to know this and very in keeping with the Erlang > approach of making bugs nice and visible. So my vote while we're all > requesting changes to Erlang :) is for more line number visibility. > > On a related subject I've played around with the LINE macro to tag > my own logging/error messages with line numbers and the best I could > produce was something like this : > > -define(log(Line, Message, Var), log_message(?MODULE, Line, Message, > ??Var, Var)). % LINE macro always gives '1' if I put it here. > > log_message(Module, Line, Message, VarName, Var) -> > io:format("log: {~p, ~p} ~s ~s = ~p~n", [Module, Line, Message, > VarName, Var]). > > and then in my code I can do things like > > ?log(?LINE, "Unexpected post", Other), > > This works fine, but it would be nice to just write > > ?log("Unexpected post", Other), > > and get the line number somehow. Can this be done? > > > Richard. > > > -- > --Hynek (Pichi) Vychodil - Show quoted text -