Skip to content

Exception tracking and logging from Elixir to Rollbar

License

Notifications You must be signed in to change notification settings

gullitmiranda/rollbax

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rollbax

Build Status Hex Version

Elixir client for Rollbar.

Installation

Add Rollbax as a dependency to your mix.exs file:

defp deps() do
  [{:rollbax, "~> 0.6"}]
end

and add it to your list of applications:

def application() do
  [applications: [:rollbax]]
end

Then run mix deps.get in your shell to fetch the dependencies.

Usage

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())
end

For detailed information on configuration and usage, take a look at the online documentation.

Logger backend

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: :error

Sending 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)

For more information, check out the documentation for Rollbax.Logger.

Plug and Phoenix

For examples on how to take advantage of Rollbax in Plug-based applications (including Phoenix applications), have a look at the "Using Rollbax in Plug-based applications" page in the documentation.

Non-production reporting

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: :log

Contributing

To run tests, run $ mix test --no-start. The --no-start bit is important so that tests don't fail (because of the :rollbax application being started without an :access_token specifically).

When making changes to the code, adhere to this Elixir style guide.

Finally, thanks for contributing! :)

License

This software is licensed under the ISC license.

About

Exception tracking and logging from Elixir to Rollbar

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Elixir 100.0%