MLH/mlh-no-light

Setup Airbrake for your Sinatra application

Opened this issue · 0 comments

bih commented

Installation

Using bundler

Add the Airbrake gem to your Gemfile:

gem 'airbrake', '~> 6.0'

Manual

Invoke the following command from your terminal:

gem install airbrake

Configuration

To use Airbrake with Sinatra, simply require the gem, configure it and use our Rack middleware (You can find your project ID and API KEY with your project's settings):

# myapp.rb
require 'sinatra/base'
require 'airbrake'

Airbrake.configure do |c|
  c.project_id = <Your project ID>
  c.project_key = '<Your project API KEY>'

  # Display debug output.
  c.logger.level = Logger::DEBUG
end

class MyApp < Sinatra::Base
  use Airbrake::Rack::Middleware

  get('/') { 1/0 }
end

run MyApp.run!

For more information please visit our official GitHub repo.