[erlang-questions] logging with email output

Michael McDaniel erlangy@REDACTED
Thu Nov 20 23:05:59 CET 2008


 I add mail into my handler, e.g.


handle_event({set_alarm, {died, Ver, Reason}}, N) ->
  Host = atom_to_list(node()) ,
  D  = io_lib:format("~w/~w/~w ", tuple_to_list(date())) ,
  T  = io_lib:format("~w:~w:~w ", tuple_to_list(time())) ,
  DT = string:concat(D,T) ,
  Subj = "die whatever_it_is_that_died "++Host++Ver++"\n("++Reason++")", 
  Msg  = DT++Subj ,

  spawn(?MODULE, send, ["<from@REDACTED>", "<to@REDACTED>", Subj, Msg]),

  {ok, N+1}
;
handle_event( another event ) ->
&etc...
.


?MODULE:send/4 being a wrapper around whatever email you want to use;
see  http://www.trapexit.org/Special:UserContributions  for some
choices.


~Michael



On Thu, Nov 20, 2008 at 03:45:01PM -0600, Adam Duston wrote:
> In my Java application, I can use an email logging target with log4j
> and then, when an exception occurs, an email is politely delivered to
> my inbox. In my Erlang app, I'm logging info and errors using
> error_logger. I would like to be notified by email when one of my
> gen_servers trips badly enough to shutdown and get restarted by the
> supervisor. What is the idiomatic way to do this?
> 
> Thanks,
> Adam
> 
> -- 
> Founder, 8 Planes
> adam@REDACTED
> Skype: aduston
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 
Michael McDaniel
Portland, Oregon, USA
http://autosys.us




More information about the erlang-questions mailing list