Elixir client for Rollbar.
Add Rollbax as a dependency to your mix.exs file:
defp deps() do
[
{:rollbax, "~> 0.6", github: "noma4i/rollbax"}
]
endand add it to your list of applications:
def application() do
[
applications: [
:rollbax
]
]
endThen run mix deps.get in your shell to fetch the dependencies.
Rollbax requires some configuration in order to work. For example, in config/config.exs:
config :rollbax,
access_token: "ffb8056a621f309eeb1ed87fa0c7",
environment: "production"Then, exceptions (errors, exits, and throws) can be reported to Rollbar using Rollbax.report/3:
try do
DoesNotExist.for_sure()
rescue
exception ->
Rollbax.report(:error, exception, System.stacktrace())
endFor detailed information on configuration and usage, take a look at the online documentation.
Rollbax provides a backend for Elixir's Logger as the Rollbax.Logger module. It can be configured as follows:
# We register Rollbax.Logger as a Logger backend.
config :logger,
backends: [Rollbax.Logger]
# We configure the Rollbax.Logger backend.
config :logger, Rollbax.Logger,
level: :errorSending logged messages to Rollbar can be disabled via Logger metadata:
# To disable reporting for all subsequent logs:
Logger.metadata(rollbar: false)
# To disable reporting for the current logged message only:
Logger.error("oops", rollbar: false)usage goes here
Rollbax can ignore errors by their Exception module name. For example, to ignore 404s in Phoenix, you can use the following config option
config :rollbax, ignore_list: [Phoenix.Router.NoRouteError]For non-production environments error reporting can be either disabled completely (by setting :enabled to false) or replaced with logging of exceptions (by setting :enabled to :log).
config :rollbax, enabled: :logThis software is licensed under the ISC license.