h1. erlbrake
An Erlang client for the "Airbrake":http://airbrake.io/ exception notification service (formerly known as Hoptoad).
h2. Requirements
h2. Usage
h3. Running the Erlbrake application
ERL_LIBS="$HOME/erlang/ibrowse:$HOME/erlang/erlbrake:$ERL_LIBS" erl -erlbrake apikey '"76fdb93ab2cf276ec080671a8b3d3866"' -erlbrake error_logger true -erlbrake environment '"development"' -s erlbrake start
1> airbrake:notify(error, fake, "Testing erlbrake with a manual error report", no_module, 0).
ok
2> error_logger:error_msg("A sample error caught by the erlbrake error logger.").
...
These configuration options can be set in @ebin/erlbrake.app@, or configured on the command line as in the above example.
h3. Embedding Erlbrake in an existing application
{airbrake,
{airbrake, start_link, ["production", "76fdb93ab2cf276ec080671a8b3d3866"]},
permanent, 5000, worker, dynamic}.
case calculate_something() of
{ok, Value} ->
Value;
Error = {error, Reason} ->
airbrake:notify(error, Reason, "Frobber calculation failed", ?MODULE, ?LINE)
end.
and/or:
try do_stuff() of
Value ->
Value
catch
Type:Reason ->
airbrake:notify(Type, Reason, "Ahhh! Stuff is not good!", ?MODULE, ?LINE, erlang:get_stacktrace())
end.
error_logger:add_report_handler(erlbrake_error_logger)
h2. Macro
A macro similar to this is likely useful to avoid duplication:
-define(NOTIFY_AIRBRAKE(Type, Reason, Message),
airbrake:notify(Type, Reason, Message, ?MODULE, ?LINE, erlang:get_stacktrace())).
If you already have a macro to log errors, just add it to that :)