Erlang - Event & Log

Event Manager

Event Manager can be created by calling "gen_event:start_link/0(1)". Event Manager has its own Process. Send events to the created Event Manager by "gen_event:notify/2".
Application "Kernel" has a default Event Manager, named "error_logger". It is recommended to use this Event Manager to report errors, warnnings, information and custom events.
Application "SASL" has a Event Manager, named "alarm_handler". It also contain a simple alarm handler in it with the same name.


Event Handler

One Event Manager can have/add/install one or more Event Handlers, which is an implementation of OTP behaviour "gen_event". Event Handler run in the Event Manager Process.
Application "Kernel" has a default Event Handler added/installed to Event Manager "error_logger", which can be configurable by "Kernel" Application Configuration parameter "error_handler".
Application "SASL" has an Event Handler added/installed to Event Manager "error_logger" as well, which will output OTP behaviours logs to tty by default. It can be configurable by "SASL" Application Configuration parameter "sasl_error_logger".


custom Event Handler

Implement OTP behaviour "gen_event" and add/install it to an Event Manager ("error_logger" or a self created Event Manager).


custom Event type for Event Manager "error_logger"

Use
error_logger:info_report/2,
error_logger:warning_report/2
error_logger:error_report/2
to report custom Events.
Implement a custom Event Handler(gen_event) and add it to "error_logger" to handle the custom Event type.