[erlang-questions] Newbie: at what point should an event handler be installed?

Robert Raschke rtrlists@REDACTED
Tue May 6 13:07:03 CEST 2014


Hi Frans,

you would add the handler at the point you want it to start handling
events. So, probably just before your fsm kicks off, I would have thought.

You can have your supervisor be in charge of starting first your event
manager and then your fsm, and have the start_link or init of your fsm add
your event handler to the manager. I'm assuming your fsm is the place that
produces the events and that they're reasonably specific to your app, so
adding the handler there makes sense to me.

Hope this helps,
Robby
 On May 6, 2014 9:27 AM, "Schneider" <schneider@REDACTED> wrote:

> Hi list,
>
> I have a very basic application with a supervisor started which starts a
> gen_fsm which handles some serial line data and a gen_event process which
> should log some of the serial line data to a mnesia table. I want to
> implement the logging to the mnesia table as an event handler. At what
> point does one install the event handler using gen_event:add_handler.
> Logging to the database is always on, but logging to the terminal is
> optional.
> Installing the handler at the application level after starting the
> supervisor works but does not feel right, nor does the supervisor.
> Could you give me some advice?
> Thanks.
>
> Frans
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140506/cc68856e/attachment.htm>


More information about the erlang-questions mailing list