[erlang-questions] how to trace gen_servers?

Scott Lystig Fritchie fritchie@REDACTED
Wed Nov 28 20:46:47 CET 2007


I haven't seen a reply yet to this message ...

>>>>> "mk" == Matej Kosik <kosik@REDACTED> writes:

mk> Is there a way how to customize information that gets logged into
mk> file when I turn on the `log_to_file' option for my gen_servers?

I don't see an easy one.  A quick read of the mechanism in stdlib's
sys.erl suggests that it's configurable via a handler func (FormFunc),
but I don't see how to override the default in gen_server.  If there
is such a thing, it's hiding well.  :-)

You probably want to use the system trace facility, anyway.  It's much
more flexible, at the expense of being more flexible and thus more
difficult to use.  See the 'dbg' module (in the docs: Tool
Applications -> runtime_tools -> dbg) or the tracing frameworks built
on top of dbg (in the docs: Tool Applications -> et or inviso or
observer).

mk> Not very nice but partially useful. The state (dictionary) is
mk> serialized in unusable way but this is not the primary problem.

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.

You can also write your own gen_server behavior that'll do exactly the
logging that you want, then call gen_server:CallBackFunc() to do your
"real work".

-Scott




More information about the erlang-questions mailing list