erlang - Meaningful auto-generated name for PID for debug purposes? -
there's process started task.supervisor.start_child
, if went wrong elixir (erlang) prints error message this:
23:56:06.257 [error] task #pid<0.216.0> started #pid<0.137.0> terminating
it's hard understand process crashed. wonder if there's way give meaningful auto-generated names processes? error more descriptive, like:
23:56:06.257 [error] task #pid-request-handler<0.216.0> started #pid-socket-loop<0.137.0> terminating
you can name each desired process register/2
function:
erlang:
register(regname, pidorport) -> true
elixir:
register(pid | port, atom) :: true
then need implementing logger use process_info(pid, registered_name)
function registered name of desired process pid , formatting log text name.
update: know error_logger
event manager (gen_event). error, warning, crash, progress , info events sent error logger erlang runtime system , different erlang/otp applications. has default event handlers, sasl
otp application adds more logging features application. can write own event handler , add error_logger
event manager.
Comments
Post a Comment