[erlang-questions] how to trace gen_servers?

Matej Kosik kosik@REDACTED
Thu Nov 29 14:09:29 CET 2007

Hash: SHA1

Ulf Wiger (TN/EAB) wrote:
> Scott Lystig Fritchie skrev:
>> That's the way dicts look.  Ulf Wiger's recently-discussed shell
>> hackery wouldn't make those look any different, because (AFAIK) his
>> shell hooks wouldn't be called by io_lib:format() or whatever is doing
>> that formatting.
> Actually, it might. (:
> At least I started looking at that. I was trying to come up with a
> good way for e.g. dict to register an output filter, so that each
> shell instance would automatically (configurably) pick it up.
> Each call to io:format(Format, Args) actually results in a message,
> {put_chars,io_lib,format,[Format,Args]} to an io server, so it could
> of course be trapped and in part diverted to io_lib_pretty:print(Term,
> ...), which is the function that is able to do the filtering.
> The problem lies in that the Erlang IO subsystem is so pluggable,
> that it's difficult to know just what code is going to process
> the io_request, and for what purpose. In many cases, automatic
> filtering could be every bit as bad as it would be to automatically
> truncate the output and replace with "...", as the shell tends
> to do. Finding out how to turn on filtering in just the right
> processes, and only when desired, was the tricky part, which
> I decided to leave for (much) later.

Ok. Thank you both.

I have solved my problem. Not in such a smart way but it works for me.

I need to see the progress of processes and various values of various variables as they change over

	29.11.2007 14:0:6 circuit_monitor:423
	29.11.2007 14:0:6 circuit_monitor:504
	29.11.2007 14:0:6 circuit_monitor:475
	29.11.2007 14:0:6 circuit_monitor:532
	29.11.2007 14:0:6 circuit_monitor:307 {6,113}
	29.11.2007 14:0:6 circuit_monitor:570
	29.11.2007 14:0:6 control_channel:105
	<request id="69">
	    <from>11/28/2007 14:0:0</from>
	    <to>11/29/2007 14:0:0</to>
	29.11.2007 14:0:6 circuit_monitor:570
	29.11.2007 14:0:6 utils:95
	<response id="69" status="0">

	29.11.2007 14:0:8 circuit_monitor:168
	29.11.2007 14:0:8 circuit_monitor:31
	29.11.2007 14:0:8 circuit_monitor:159
	29.11.2007 14:0:8 circuit_monitor:202 {5,active}
	29.11.2007 14:0:8 circuit_monitor:360
	29.11.2007 14:0:8 circuit_monitor:370
	29.11.2007 14:0:8 circuit_monitor:556

That is: progress of processes over time as a sequence of lines each with the following information:
- - date
- - time
- - filename
- - line number
- - optionally: the variable value I am in a given place interested in
and now I have this in a permanent log. Not very inteligent (logs grow) but for debugging the only
way how can I find out ex post what went wrong at 3:00 AM yesterday.

The disadvantage is, that I must enter in the code instructions such as


... print the "stamp" (date/time/filename/line-number)


... print the "stamp" together with a given string


... print the "stamp" together with a given term

Best regards
- --
Matej Kosik
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


More information about the erlang-questions mailing list