I am working on a decentralized Erlang application. I am currently working on a single PC and creating multiple nodes by initializing erl
with the -sname
You can supply 1st argument to io:format/3 on the second node, using result of erlang:group_leader() from the first node.
Starting first node, registering local shell process group leader globally:
erl -sname a
(a@localhost)1> global:register_name(global_io_srv, group_leader()).
yes
Starting second node, connecting, using globally registered process as io device
erl -sname b
(b@localhost)1> net_kernel:connect(a@localhost).
true
(b@localhost)2> io:format(global:whereis_name(global_io_srv),"test output",[]).
ok
You will see test output in the first node. This is the same way that Christian suggested, just a bit more explicit. So you can have error_logger for production logging and io:format/3 just for quick debugging.