Bugsnag Elixir Build Status

Capture exceptions and send them to the Bugsnag API!

Installation

# Add it to your deps in your projects mix.exs
defp deps do
  [{:bugsnag, "~> 1.4.0"}]
end

# Now, list the :bugsnag application as your application dependency:
def application do
  [applications: [:bugsnag]]
end

# Open up your config/config.exs (or appropriate project config)
config :bugsnag, api_key: "bbf085fc54ff99498ebd18ab49a832dd"

# Set the release stage in your environment configs (e.g. config/prod.exs)
config :bugsnag, release_stage: "prod"

# Set `use_logger: true` to report all uncaught exceptions (using Erlang SASL)
config :bugsnag, use_logger: true

Usage

Configuration

You can use environment variables in order to set up all options. You can set default variable names, and don’t touch config files, eg:

Or you can define from which env vars it should be loaded, eg:

config :bugsnag, :api_key,        {:system, "YOUR_ENV_VAR" [, optional_default]}
config :bugsnag, :release_stage,  {:system, "YOUR_ENV_VAR" [, optional_default]}
config :bugsnag, :ues_logger,     {:system, "YOUR_ENV_VAR" [, optional_default]}

Ofcourse you can use regular values as in Installation guide.

Manual reporting

# Report an exception.
try do
  :foo = :bar
rescue
  exception -> Bugsnag.report(exception)
end

In some cases you might want to send the report synchronously, to make sure that it got sent. You can do that with:

# ...an exception occured
  Bugsnag.sync_report(exception)

Options

These are optional fields to fill the bugsnag report with more information, depending on your specific usage scenario. They can be passed into the Bugsnag.report/2 function like so:

# ...an exception occured
  Bugsnag.report(exception, severity: "warn", user: %{name: "Jane Doe"})

Logger

Set the use_logger option to true in your application’s config.exs. So long as :bugsnag is started, any SASL compliant processes that crash will send an error report to the Bugsnag.Logger. The logger will take care of sending the error to Bugsnag.